ProgramixGenericLib v5.0.1

com.programix.sql
Class UniqueIDGenerator

java.lang.Object
  extended by com.programix.sql.UniqueIDGenerator

public class UniqueIDGenerator
extends Object

Sets up a simple, thread-safe, unique id generator that uses a database table to control concurrency.

The ValueMap passed can be created from a file that looks something like this:

 sql.id.generator.table.name=id_list
 sql.id.generator.match.column.name=name
 sql.id.generator.id.column.name=last_id
 

Author:
Paul Hyde

Field Summary
static String ID_COLUMN_KEY
           
static String MATCH_COLUMN_KEY
           
static String TABLE_NAME_KEY
           
 
Constructor Summary
UniqueIDGenerator(ConnectionSource connectionSource, String tableName, String matchColumnName, String idColumnName)
           
UniqueIDGenerator(ConnectionSource connectionSource, ValueMap config)
           
 
Method Summary
 int generateUniqueID(String tableName)
           
 int generateUniqueID(String tableName, Connection con)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TABLE_NAME_KEY

public static final String TABLE_NAME_KEY
See Also:
Constant Field Values

MATCH_COLUMN_KEY

public static final String MATCH_COLUMN_KEY
See Also:
Constant Field Values

ID_COLUMN_KEY

public static final String ID_COLUMN_KEY
See Also:
Constant Field Values
Constructor Detail

UniqueIDGenerator

public UniqueIDGenerator(ConnectionSource connectionSource,
                         String tableName,
                         String matchColumnName,
                         String idColumnName)

UniqueIDGenerator

public UniqueIDGenerator(ConnectionSource connectionSource,
                         ValueMap config)
                  throws ValueMapException
Throws:
ValueMapException
Method Detail

generateUniqueID

public int generateUniqueID(String tableName)
                     throws SQLException
Throws:
SQLException

generateUniqueID

public int generateUniqueID(String tableName,
                            Connection con)
                     throws SQLException
Throws:
SQLException

ProgramixGenericLib v5.0.1

Copyright © 2001-2009 Programix Incorporated. All rights reserved. ProgramixGenericLib is free and is OSI Certified Open Source Software under the BSD license.