tags:

views:

106

answers:

3

hi, i want to know how to create GUID number in java ee , i am using jboss 4.2.3

+2  A: 
import java.util.UUID;

UUID uuid = UUID.randomUUID();

String randomUUIDString = uuid.toString();
Otávio Décio
+3  A: 
import java.util.UUID;

...
UUID id = UUID.randomUUID();

When identifiers are used solely within a database, their generation should be left to the database itself. See Statement.getGeneratedKeys

UUID Javadoc

stacker
+1  A: 

To generate UUID in Java you can use the java.util.UUID class. This class was introduced in JDK 1.5

import java.util.UUID;

UUID uuid = UUID.randomUUID();
String randomUUIDString = uuid.toString();
System.out.println("Random UUID String = " + randomUUIDString);
System.out.println("UUID version       = " + uuid.version());
System.out.println("UUID variant       = " + uuid.variant());
JuanZe