sql - java- generate id (combination of string and integer) -
I am creating an application in NetBeans (java). This app has unique ID combinations of string and integers like The problem is that the increase in the value of the integer part until it reaches proper 10, but after that it does not increase for further entries in the database. I try the following code - " Integer increment of 10" "means that if I start the first value of the id in the database such as but when this If anyone has any other option to generate The problem is that The alphabetic order will be described as descending, And speaking alphabetically And that's why your program always fetches 9 times and more frequently ... I think you'll find that column Will have to split up for storage, and store the numerical part as a real number type in the database. It's probably not as hard as it seems, you can always sort on 2 fields abc / 111 or
xyz / 253 and should increase the integer part when there is a new entry in the database
ABC / 112 and
xyz / 254 .
{string sql = "death number by resigner dessc select number from;"; Pst = conn.prepareStatement (SQL); Rs = pst.executeQuery (); If (rsnext ()) {string add1 = rs.getString ("RegNumber"); String [] parts = add1.split ("/"); String part 1 = parts [0]; String Part 2 = Part [1]; Int a, b; A = integer Parasont (Part 2); B = A + 1; JTextField20.setText ("" + part1 + "/" + b); Yosepepationpen Show Messagidoug (blank, "done"); }}
abc / 1 < / Code> then the new ID automatically generates a rising value of 1 for the next entry, which is
abc / 2 and for the next entry it will be
abc / 3 And similar sequential
abc / 4 , ...,
abc / 10
abc / 10 New Generated ID is one for every new entry in the database I.e. means
abc / 10 (I am using MS Access 2007 and type
id of
text ). The first ID in the database Created by yourself.
id , then please let me know.
string = "RegNumber selects RegNumber from the order of death by DESC";
"abc / 9" & gt; "ABC / 10"
string by registering sql = "Regstring DESC, by RegNumber DESC, select RegNumber"; You can consider using a
SERIAL (autoincrement) datatype for the RegNumber part in some cases (ie if RegNumber is not reset such as when String part changes) to further your entry logic.
Comments
Post a Comment