public abstract class AbstractGenericDatabase extends java.lang.Object implements IDatabase
Constructor and Description |
---|
AbstractGenericDatabase() |
Modifier and Type | Method and Description |
---|---|
void |
closeConnection(java.sql.Connection connection)
This is used to close a connection.
|
void |
closeDatabaseResources(java.sql.Connection connection,
java.sql.PreparedStatement stmt,
java.sql.ResultSet rs)
This is used to make sure that all DB resources are closed.
|
void |
commitTransactionConnection(java.sql.Connection connection)
This is used to commit a connection to the database
|
java.sql.Connection |
createTransactionConnection()
This is used to get a non-auto-committing connection to the database from a datasource
|
boolean |
dropTable(java.lang.String tableName)
This is called to delete a table from the database It creates it's own connection too the DB
|
void |
executeSQL(java.lang.String sql)
This is used to execute a simple SQL statement on the database.
|
long |
executeUpdate(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object[] params)
This is used to execute an update statement that takes parameters.
|
long |
executeUpdate(java.lang.String sql,
java.lang.Object[] params)
This is used to execute an update statement that takes parameters.
|
java.sql.PreparedStatement |
getStatement(java.sql.Connection connection,
java.lang.String sql,
java.lang.Object[] params)
This is used to create a PreparedStatement from the given SQL.
|
long |
insertIntoTable(java.sql.Connection connection,
java.lang.String tableName,
java.util.List<Field> fields)
This is used to insert table row into a table.
|
long |
insertIntoTable(java.lang.String tableName,
java.util.List<Field> fields)
This is used to insert table row into a table.
|
void |
rollbackTransactionConnection(java.sql.Connection connection)
This is used to rollback all statements pushed through this connection since the last commit or save from the database
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
createConnection, dropTable, executeSQL, getStatement, init
public java.sql.Connection createTransactionConnection() throws java.sql.SQLException
createTransactionConnection
in interface IDatabase
java.sql.SQLException
- Thrown if their is a problem getting the connection to the
databasejava.sql.SQLException
- Thrown if their is a problem talking to the databasepublic void commitTransactionConnection(java.sql.Connection connection) throws java.sql.SQLException
commitTransactionConnection
in interface IDatabase
connection
- This connection is committedjava.sql.SQLException
- Thrown if there is a problem getting the connection to the databasepublic void rollbackTransactionConnection(java.sql.Connection connection)
rollbackTransactionConnection
in interface IDatabase
connection
- This connection is rolled backpublic void closeDatabaseResources(java.sql.Connection connection, java.sql.PreparedStatement stmt, java.sql.ResultSet rs)
closeDatabaseResources
in interface IDatabase
connection
- the connection to closestmt
- the statement to closers
- the result set to closepublic void closeConnection(java.sql.Connection connection) throws java.sql.SQLException
closeConnection
in interface IDatabase
connection
- The connection to closejava.sql.SQLException
- Thrown if their is a problem talking to the databasepublic boolean dropTable(java.lang.String tableName)
public void executeSQL(java.lang.String sql) throws java.sql.SQLException
executeSQL
in interface IDatabase
sql
- the SQL to execute on the databasejava.sql.SQLException
- Thrown if their is a problem talking to the databasepublic java.sql.PreparedStatement getStatement(java.sql.Connection connection, java.lang.String sql, java.lang.Object[] params) throws java.sql.SQLException
getStatement
in interface IDatabase
connection
- a connection to the databasesql
- the statements SQLparams
- the parameters to place into the statementjava.sql.SQLException
- thrown if their is a problem creating the statementPreparedStatement
public long executeUpdate(java.lang.String sql, java.lang.Object[] params) throws java.sql.SQLException
executeUpdate
in interface IDatabase
sql
- the SQL to execute on the databaseparams
- the parameters to insert into the SQL statement, replacing ?.java.sql.SQLException
- Thrown if their is a problem talking to the databasepublic long executeUpdate(java.sql.Connection connection, java.lang.String sql, java.lang.Object[] params) throws java.sql.SQLException
executeUpdate
in interface IDatabase
connection
- a connection to be re-used, useful for running a series of updates as a
transactionsql
- The SQL to execute on the databaseparams
- the parameters to insert into the SQL statement, replacing ?.java.sql.SQLException
- Thrown if their is a problem talking to the databasepublic long insertIntoTable(java.sql.Connection connection, java.lang.String tableName, java.util.List<Field> fields) throws java.sql.SQLException
insertIntoTable
in interface IDatabase
connection
- a connection to be re-used, useful for running a seriestableName
- The name of the tablefields
- The fields of the table that are to be inserted.java.sql.SQLException
- Thrown if their is a problem talking to the databasepublic long insertIntoTable(java.lang.String tableName, java.util.List<Field> fields) throws java.sql.SQLException
insertIntoTable
in interface IDatabase
tableName
- The name of the tablefields
- The fields of the table that are to be inserted.java.sql.SQLException
- Thrown if their is a problem talking to the database