public interface IDatabase
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 |
createConnection()
This is used to get a connection to the database
|
java.sql.Connection |
createTransactionConnection()
This is used to get a connection to the database
|
boolean |
dropTable(java.sql.Connection connection,
java.lang.String tableName)
This is called to delete a table from the database.
|
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.sql.Connection connection,
java.lang.String sql)
This is used to execute a simple SQL statement on the database.
|
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 a update state that takes params.
|
long |
executeUpdate(java.lang.String sql,
java.lang.Object[] params)
This is used to execute a update state that takes params.
|
java.sql.PreparedStatement |
getStatement(java.sql.Connection connection,
java.lang.String sql)
This is used to create a PreparedStatement from the give SQL.
|
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.
|
void |
init()
This is used to setup the database manager class, it should be called after creating a
database manager class.
|
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
|
void init() throws UnableToConnectToDatabaseException
UnableToConnectToDatabaseException
- Thrown if unable to connect to the databasejava.sql.Connection createConnection() throws java.sql.SQLException
java.sql.SQLException
- Thrown if there is a problem getting the connection to the databasejava.sql.Connection createTransactionConnection() throws java.sql.SQLException
java.sql.SQLException
- Thrown if there is a problem getting the connection to the databasevoid commitTransactionConnection(java.sql.Connection connection) throws java.sql.SQLException
connection
- This connection is committedjava.sql.SQLException
- Thrown if there is a problem getting the connection to the databasevoid rollbackTransactionConnection(java.sql.Connection connection)
connection
- This connection is rolled backvoid executeSQL(java.lang.String sql) throws java.sql.SQLException
sql
- The SQL to execute on the databasejava.sql.SQLException
- Thrown if their is a problem talking to the databasevoid executeSQL(java.sql.Connection connection, java.lang.String sql) throws java.sql.SQLException
connection
- a connection to be re-used, useful for running a series
of updates as a transactionsql
- the SQL to execute on the databasejava.sql.SQLException
- Thrown if their is a problem talking to the databaselong executeUpdate(java.lang.String sql, java.lang.Object[] params) throws java.sql.SQLException
sql
- The SQL to execute on the databaseparams
- The params to insert into the SQL statement.java.sql.SQLException
- Thrown if their is a problem talking to the databaselong insertIntoTable(java.sql.Connection connection, java.lang.String tableName, java.util.List<Field> fields) throws java.sql.SQLException
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 databaselong insertIntoTable(java.lang.String tableName, java.util.List<Field> fields) throws java.sql.SQLException
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 databaselong executeUpdate(java.sql.Connection connection, java.lang.String sql, java.lang.Object[] params) throws java.sql.SQLException
connection
- A connection to the databasesql
- The SQL to execute on the databaseparams
- The params to insert into the SQL statement.java.sql.SQLException
- Thrown if their is a problem talking to the databaseboolean dropTable(java.lang.String tableName)
tableName
- The table to deleteboolean dropTable(java.sql.Connection connection, java.lang.String tableName)
tableName
- The table to deleteconnection
- The database connectionjava.sql.PreparedStatement getStatement(java.sql.Connection connection, java.lang.String sql) throws java.sql.SQLException
connection
- A connection to the databasesql
- The statements sqljava.sql.SQLException
- Thrown if their is a problem creating the statementPreparedStatement
java.sql.PreparedStatement getStatement(java.sql.Connection connection, java.lang.String sql, java.lang.Object[] params) throws java.sql.SQLException
connection
- a connection to the databasesql
- the statements sqlparams
- the params to place into the statementjava.sql.SQLException
- thrown if their is a problem creating the statementPreparedStatement
void closeDatabaseResources(java.sql.Connection connection, java.sql.PreparedStatement stmt, java.sql.ResultSet rs)
connection
- The connection to closestmt
- The statement to closers
- The result set to closevoid closeConnection(java.sql.Connection connection) throws java.sql.SQLException
connection
- The connection to closejava.sql.SQLException
- Thrown if their is a problem talking to the database