public class CommonCodeImpl extends CommonCode
| Modifier and Type | Field and Description |
|---|---|
static int |
JUMP_RANGE
Starting Range of sequence id which will remain un-used for each table.
|
| Constructor and Description |
|---|
CommonCodeImpl()
default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
closeAllConnections()
Close all the connections of the pool at once.
|
void |
executeFile(String fileName)
Execute all the sql query present in the given file.
|
protected void |
finalized()
Whenever this instance is taken by garbage collection this method will be called.
|
void |
freeConnection(Connection connection)
We do re-use the instance of
Connection. |
Connection |
getConnection()
Get a free instance of
Connection from the connection pool. |
String |
getDatabaseURL()
Get the url of the database to which this instance is connected.
|
long |
getNextSequenceId(String tableName)
Get next available unique sequence id for the given table.
|
long |
getNextSequenceIdUnbuffered(String tableName)
Do the same task as described in
getNextSequenceId(String) but it will execute sql query at every call
and will not cache any range value for instance reply. |
protected void |
reload(String fileName)
Load all the configuration from the given file and save them in an instance of
DatabaseXMLDAO |
void |
run() |
getInstancepublic static final int JUMP_RANGE
getNextSequenceId(String)protected void reload(String fileName) throws Exception
DatabaseXMLDAOreload in class CommonCodefileName - Absolute or Relative path to the configuration XML file.Exception - if any occurs while parsing the configuration file.public void run()
run in class CommonCodepublic Connection getConnection() throws SQLException
Connection from the connection pool. If no connection is available, it will create
a new one and return. We must return the instance of Connection by calling method
freeConnection(Connection) once we are done with this, so that it can be saved for future re-use.getConnection in class CommonCodeConnectionSQLException - if any occurs while creating a new connection.public void freeConnection(Connection connection)
Connection. So, whenever we are done with an instance of Connection
we must return it to the pool for re-use in the future.freeConnection in class CommonCodeconnection - the instance of Connection to be returned in the pool.public long getNextSequenceId(String tableName) throws Exception
getNextSequenceId in class CommonCodetableName - sequence id will be generated unique for this table.Exception - if any occurs while executing sql query.public String getDatabaseURL()
getDatabaseURL in class CommonCodepublic void closeAllConnections()
closeAllConnections in class CommonCodepublic long getNextSequenceIdUnbuffered(String tableName) throws Exception
getNextSequenceId(String) but it will execute sql query at every call
and will not cache any range value for instance reply.getNextSequenceIdUnbuffered in class CommonCodetableName - sequence id will be generated unique for this table.Exception - if any occurs while executing sql query.public void executeFile(String fileName) throws Exception
executeFile in class CommonCodefileName - contains multiple sql query, which will be executed in the given sequence.Exception - if any occurs while executing sql query.protected void finalized()
finalized in class CommonCodeCopyright © 2023. All rights reserved.