public abstract class CommonCode extends Object
| Constructor and Description |
|---|
CommonCode() |
| Modifier and Type | Method and Description |
|---|---|
abstract void |
closeAllConnections()
Close all the connections of the pool at once.
|
abstract void |
executeFile(String fileName)
Execute all the sql query present in the given file.
|
protected abstract void |
finalized()
Whenever this instance is taken by garbage collection this method will be called.
|
abstract void |
freeConnection(Connection connection)
We do re-use the instance of
Connection. |
abstract Connection |
getConnection()
Get a free instance of
Connection from the connection pool. |
abstract String |
getDatabaseURL()
Get the url of the database to which this instance is connected.
|
static CommonCode |
getInstance() |
abstract long |
getNextSequenceId(String tableName)
Get next available unique sequence id for the given table.
|
abstract 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 abstract void |
reload(String fileName)
Load all the configuration from the given file and save them in an instance of
DatabaseXMLDAO |
abstract void |
run() |
public static CommonCode getInstance()
protected abstract void reload(String fileName) throws Exception
DatabaseXMLDAOfileName - Absolute or Relative path to the configuration XML file.Exception - if any occurs while parsing the configuration file.public abstract void run()
public abstract 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.ConnectionSQLException - if any occurs while creating a new connection.public abstract 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.connection - the instance of Connection to be returned in the pool.public abstract long getNextSequenceId(String tableName) throws Exception
tableName - sequence id will be generated unique for this table.Exception - if any occurs while executing sql query.public abstract String getDatabaseURL()
public abstract void closeAllConnections()
public abstract 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.tableName - sequence id will be generated unique for this table.Exception - if any occurs while executing sql query.public abstract void executeFile(String fileName) throws Exception
fileName - contains multiple sql query, which will be executed in the given sequence.Exception - if any occurs while executing sql query.protected abstract void finalized()
Copyright © 2023. All rights reserved.