kotkabeans
Class AutoNumber

java.lang.Object
  |
  +--kotkabeans.AutoNumber

public class AutoNumber
extends java.lang.Object

implements autonumber feature because it does not exists in the SQL92 standard.


Constructor Summary
AutoNumber()
          Database connection used to get next ID-values from Kotka-database.
 
Method Summary
static int getNumber(java.lang.String tableName)
          Maximum ID-values at this time are stored in the database.
static int getNumber(java.lang.String tableName, java.lang.String primaryKeyName)
           
static int lastUsedNumber(java.lang.String tableName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AutoNumber

public AutoNumber()
Database connection used to get next ID-values from Kotka-database.

Method Detail

getNumber

public static int getNumber(java.lang.String tableName)
                     throws java.lang.Exception
Maximum ID-values at this time are stored in the database. Calling this method causes these counters to increment. If no table name has been saved, it will be added and value as 1. This should also check that the return value has not been used in the table as primary key. BUT: the problem is that this method or the Autonumber table do not know the primary key column name.

Parameters:
tableName - Name of the table of which next ID-value is needed.
Returns:
Next ID-value. If error occurs this method returns -1
java.lang.Exception

getNumber

public static int getNumber(java.lang.String tableName,
                            java.lang.String primaryKeyName)
                     throws java.lang.Exception
java.lang.Exception

lastUsedNumber

public static int lastUsedNumber(java.lang.String tableName)
                          throws java.lang.Exception
java.lang.Exception