|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.stanwood.media.database.AbstractGenericDatabase
public abstract class AbstractGenericDatabase
This class contains methods for database connections that are generic for all database implementations.
Constructor Summary | |
---|---|
AbstractGenericDatabase()
|
Method Summary | |
---|---|
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 |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.stanwood.media.database.IDatabase |
---|
createConnection, dropTable, executeSQL, getStatement, init |
Constructor Detail |
---|
public AbstractGenericDatabase()
Method Detail |
---|
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
database
java.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 committed
java.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 close
java.sql.SQLException
- Thrown if their is a problem talking to the databasepublic boolean dropTable(java.lang.String tableName)
dropTable
in interface IDatabase
tableName
- The table to delete
public void executeSQL(java.lang.String sql) throws java.sql.SQLException
executeSQL
in interface IDatabase
sql
- the SQL to execute on the database
java.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 statement
java.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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |