Class Hierarchy Previous Next Index
java.lang.Object | +----COM.cloudscape.util.KeyGen
Utility class for generating unique key values.
public static final int UNIVERSAL_KEY_BYTE_LEN
public static final int UNIVERSAL_KEY_BIT_LEN
public static final int UNIVERSAL_KEY_STRING_LEN
public KeyGen()
public static byte[] getUniversalKeyValue()
The returned key is constructed in a manner that makes it extremely unlikely a KeyGen running in another database will construct the same key. This makes the generated keys useful in distributed applications. An application running at a target (or source) database may use generated key values for primary key column values when inserting rows. The rows are unlikely to conflict with rows inserted at other databases.
Returned keys are generated in a random order. This reduces contention on a backing index, when the key values are used for primary key values in a sql table.
The example below shows a typical use of this facility to construct nonconflicting keys for a table.
create table foo(k bit(128) primary key); insert into foo values (class COM.cloudscape.util.KeyGen).getUniversalKeyValue();
public static java.lang.String getUniversalKeyStringValue()
Like getUniversalKeyValue, the keys this generates are unlikely to conflict with keys generated at other databases. String keys are useful for applications that must display keys and depend on tools that do not correctly support bit data. String keys are twice as long as the keys generated by getUniversalKey.
The example below shows a typical use of this facility to construct nonconflicting keys for a table.
create table foo2(k char(32) primary key); insert into foo2 values (class COM.cloudscape.util.KeyGen).getUniversalKeyStringValue();
Class Hierarchy Previous Next Index