com.ontimize.db
Class Autonumerical
java.lang.Object
com.ontimize.db.Autonumerical
- public class Autonumerical
- extends java.lang.Object
This class implements an incremental number generator. It provides methods so
that the entities can obtain those numbers. Modification 20/05/2004: It has
been modified to allow the use of multiple counters. The current behavior is:
The table associated to the autonumerical must have the following columns: -
state - general autonumerical (numeric data type) Furthermore, it can have
additional columns in which an autonumerical associated to the column name is
stored
- Version:
- 1.0
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DEBUG
public static boolean DEBUG
SYNCHRONIZE
public static boolean SYNCHRONIZE
TABLE
public static final java.lang.String TABLE
- See Also:
- Constant Field Values
COLUMN
public static final java.lang.String COLUMN
- See Also:
- Constant Field Values
STATE_COLUMN
public static final java.lang.String STATE_COLUMN
- See Also:
- Constant Field Values
LOG_KEYS
public static final java.lang.String LOG_KEYS
- See Also:
- Constant Field Values
SAVING_CYCLE
public static final java.lang.String SAVING_CYCLE
- See Also:
- Constant Field Values
SAVING_INTERVAL
public static final java.lang.String SAVING_INTERVAL
- See Also:
- Constant Field Values
SYNCHRONIZE_VALUE
public static final java.lang.String SYNCHRONIZE_VALUE
- See Also:
- Constant Field Values
DEFAULT_SAVING_CICLE
protected static final int DEFAULT_SAVING_CICLE
- See Also:
- Constant Field Values
savingInterval
protected int savingInterval
table
protected java.lang.String table
column
protected java.lang.String column
stateColumn
protected java.lang.String stateColumn
logkeys
protected java.util.Vector logkeys
savingCycle
protected int savingCycle
staticCon
protected java.sql.Connection staticCon
columnNames
protected java.lang.String[] columnNames
autonumerical
protected int[] autonumerical
properties
protected java.util.Properties properties
databaseProperties
protected java.util.Properties databaseProperties
thread
protected Autonumerical.SavingThread thread
user
protected java.lang.String user
password
protected java.lang.String password
driver
protected java.lang.String driver
uRLDatabase
protected java.lang.String uRLDatabase
autonumericalCountSinceLastSave
protected int autonumericalCountSinceLastSave
bSynchronized
protected boolean bSynchronized
manager
protected DatabaseConnectionManager manager
forceDisconnection
protected boolean forceDisconnection
Autonumerical
public Autonumerical(java.net.URL propertyFile,
java.sql.Connection connection)
throws java.lang.Exception
- Creates a new Autonumerical object instance
- Parameters:
propertyFile - In the property file 'propertyFile' the following parameters are
included::
- Table: Table: Name of the table the last autonumerical is
stored in
- Column : Name of the column the number is stored in
- StateColumn: Name of the column the state is stored in.
Possible states: '1' correct, '0' incorrect.
- SavingCycle: Time in milliseconds between each update of the
autonumerical in the table
connection - Database connection
- Throws:
java.lang.Exception
Autonumerical
public Autonumerical(java.net.URL propertyFile,
java.net.URL urlDBProp)
throws java.lang.Exception
- Creates a new Autonumerical object instance
- Parameters:
propertyFile - In the property file 'propertyFile' the following parameters are
included::
- Table: Name of the table the last autonumerical is stored in
- Column : Name of the column the number is stored in
- StateColumn: Name of the column the state is stored in.
Possible states: '1' correct, '0' incorrect.
- LogKeys: Name of the logs which the object operations are
written in. If no log is specified, no log is made.
- SavingCycle: Time in milliseconds between each update of the
autonumerical in the table
-SavingInterval: Number of autonumericals provided before
storing the value in the table.
urlDBProp - This parameter specifies the DB connection property file. It
will have the following parameters::
- driver: JDBC driver class
- url: database url connection.
- user: database user name
- password: database password for the specified user.
- Throws:
java.lang.Exception
Autonumerical
public Autonumerical(java.net.URL propertyFile,
java.net.URL urlDBProp,
boolean createFistConnection)
throws java.lang.Exception
Autonumerical
public Autonumerical(java.net.URL propertyFile,
DatabaseConnectionManager dbConMan)
throws java.lang.Exception
Autonumerical
public Autonumerical(java.lang.String propertyFile,
DatabaseConnectionManager dbConMan)
throws java.lang.Exception
initAutonumerical
protected void initAutonumerical()
getColumnNameIndex
protected int getColumnNameIndex(java.lang.String name)
startSavingThread
protected void startSavingThread()
initConnection
protected void initConnection(java.net.URL urlDBProp,
boolean createFirstConnection)
throws java.lang.Exception
- Throws:
java.lang.Exception
getAutonumerical
public int getAutonumerical()
- Gets an sequential integer value to use as unique identifier. To ensure
that the last generated value is stored successfully in the database
tablePara executes the following mechanism:
- After 'n' requests database it updates the databse table and sets the
state as correct
- In the first request of the next 'n' autonumerical values, the states
column sets as incorrect.
- When the class is created checks if the state is correct or not. If the
state column has incorrect value automatically it sum a value to the
autonumerical number column
- Returns:
getAutonumerical
public int getAutonumerical(java.lang.String col)
incrementAutonumerical
public int incrementAutonumerical(int increment)
incrementAutonumerical
public int incrementAutonumerical(int increment,
java.lang.String col)
saveAutonumerical
protected boolean saveAutonumerical()
increment
protected int increment(java.lang.String column)
throws java.lang.Exception
- Throws:
java.lang.Exception
save
protected void save()
throws java.lang.Exception
- Throws:
java.lang.Exception
setIncorrectState
protected boolean setIncorrectState()
reconnection
protected java.sql.Connection reconnection()
throws java.lang.Exception
- Throws:
java.lang.Exception
finalize
protected void finalize()
throws java.lang.Throwable
- Throws:
java.lang.Throwable
logToLogKeys
protected void logToLogKeys(java.lang.String s)
logToLogKeys
protected void logToLogKeys(java.lang.String s,
boolean newLine)
getCurrentThreadMethods
protected java.lang.String getCurrentThreadMethods(java.lang.Throwable e,
int lines)
activateForceDisconnection
public void activateForceDisconnection()
throws java.lang.Exception
- Throws:
java.lang.Exception
disactivateForceDisconnection
public void disactivateForceDisconnection()
throws java.lang.Exception
- Throws:
java.lang.Exception
isForceDisconnectionEnabled
public boolean isForceDisconnectionEnabled()
isSynchronized
public boolean isSynchronized()