The UUID (universally unique Identifier) Globally unique identifier, which is a number generated on a machine that guarantees that all machines in the same time and space are unique. Based on the standard calculations developed by the Open Software Foundation (OSF), Ethernet card addresses, nanosecond time, chip ID codes, and many possible numbers are used. A combination of the following: the current date and time (the first part of the UUID is related to the time, if you generate a UUID after a few seconds, the first part is different, the rest is the same), the clock sequence, the globally unique IEEE Machine identification number (if there is a network card, from the network card, No network cards are available in other ways, the only drawback to the UUID is that the resulting string will be longer.
Injava There are several main ways to generate UUID:  
jdk1.5
java . util. UUID, can be called directly.  
uuid uuid = uuid.randomuuid () ;
string s = uuid.randomuuid (). toString ();/ The primary key ID used to generate the database is very good.    
uuid is made up of a 16-bit number, Forms such as
550e8400-e29b-11d4-a716-446655440000
Here is the tool class that implements obtaining a unique primary key ID for the database
650) this.width=650; "src=" Http://common.cnblogs.com/images/copycode.gif "alt=" Copy Code "style=" margin:0px;padding:0px ; border:none; "/>
Package Com.cn.util;import Java.util.uuid;public class Uuidutil {public static string Get32uuid () {string UUID = Uuid.randomuuid (). toString (). Trim (). ReplaceAll ("-", "" "); return UUID; } public static void Main (string[] args) {System.out.println (Get32uuid ()); }}
650) this.width=650; "src=" Http://common.cnblogs.com/images/copycode.gif "alt=" Copy Code "style=" margin:0px;padding:0px ; border:none; "/>
This article is from the "Yang Hailong blog" blog, make sure to keep this source http://7218743.blog.51cto.com/7208743/1906823
Use Java.util.UUID to generate a unique ID (used to make the database primary key useful)