package mypackage1; import com.sun.xml.registry.ebxml.util.UUID; import com.sun.xml.registry.ebxml.util.UUIDFactory; import java.sql.*; /* CREATE TABLE uuids ( uuid VARCHAR2(40) NOT NULL, hash_code NUMBER(10) ); ALTER TABLE uuids ADD ( CONSTRAINT uuids_uk UNIQUE (uuid) ); */ public class UUIDDemo { public UUIDDemo() { try { UUID uuid; DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@server01:1521:SID1", "USERNAME", "PASSWORD"); String sql = ""; sql += "INSERT INTO uuids (uuid, hash_code) VALUES (?,?)"; conn.setAutoCommit(false); PreparedStatement pstmt = conn.prepareStatement(sql); long start = System.currentTimeMillis(); for (int i=0; i<100000; i++) { uuid = UUIDFactory.getInstance().newUUID(); pstmt.setString(1, uuid.toString()); pstmt.setDouble(2, uuid.hashCode()); int res = pstmt.executeUpdate(); } conn.commit(); System.out.println("Elapsed: " + (System.currentTimeMillis() - start)); pstmt.close(); conn.close(); } catch (SQLException ex) { System.out.println(ex.getLocalizedMessage()); } } public static void main (String[] args) { new UUIDDemo(); } }