Why use a UUID instead of a growth model?
First, why use a UUID to control the primary key?
What is the advantage of comparing the primary key of an automatically growing int type.
When the amount of data is much, the number of logged-in users, encountered high concurrency, the growth is not conducive to maintenance, but also not conducive to expansion, and there may be several people at the same time inserted from the growth of the same ID such as from the growth of 100,ABC three users at the same time will not appear at the same time Insert 101. or cover 101 of data. That's the downside.
However, a UUID-controlled Word automatically generates an identification number when the invocation is inserted ...
generate a 32-bit UUID string
<span style= "FONT-SIZE:14PX;" >package Com.cmcc.tools;
Import Java.util.UUID;
public class Uuidtool {public
Uuidtool () {
}
/**
* automatically generates a 32-bit UUID, which is used to insert the primary key ID of the corresponding database.
* @return */public
static String Getuuid () {
/*uuid UUID = Uuid.randomuuid ();
String str = uuid.tostring ();
Remove the "-" symbol
String temp = str.substring (0, 8) + str.substring (9)
+ str.substring (+) + str.substring (19, )
+ str.substring (in);
Return temp;*/return
uuid.randomuuid (). toString (). Replace ("-", "");
}
public static void Main (string[] args) {
// string[] ss = Getuuid;
for (int i = 0; i < i++) {
System.out.println ("ss[" + i + "]=====" + getuuid ());
}}} </span>