I am making an application in NetBeans (java). This application has unique id combination of string and integer like abc/111
or xyz/253
and the integer part should increase by when a new entry takes place in the database i.e. abc/112
and xyz/254
.
The problem is the value of integer part increase until it has reached 10 in a proper way but after that it does not increase and remain same for further entries in database.
I used the following code -
try{
String sql = "SELECT RegNumber FROM Death ORDER BY RegNumber DESC ";
pst = conn.prepareStatement(sql);
rs = pst.executeQuery();
if (rs.next()) {
String add1 = rs.getString("RegNumber");
String[] parts= add1.split("/");
String part1= parts[0];
String part2= parts[1];
int a,b;
a= Integer.parseInt(part2);
b=a+1;
jTextField20.setText(""+part1+"/"+b);
JOptionPane.showMessageDialog(null, "done");
}
}
"Integer part increase till 10" means that if I start the first value of id in database like abc/1
then new id generates automatically for the next entry with the increasing value 1 that is abc/2
and for next entry it is abc/3
and so on in sequential order like this: abc/4
, ..., abc/10
But when it has reached abc/10
the new generated id remains same i.e. abc/10
for every new entry in database. (I am using MS Access 2007 and the id
is of text
type). The first id in the database is created by the application itself.
If anyone has another alternative to generate id
, please tell me.