public class HSQLDatabase extends AbstractGenericDatabase implements IDatabase
Constructor and Description |
---|
HSQLDatabase(java.lang.String host,
java.lang.String username,
java.lang.String password,
java.lang.String database)
Used to create a MYSQL database controller class.
|
Modifier and Type | Method and Description |
---|---|
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.
|
java.sql.Connection |
createConnection()
This is used to get a connection to the database to the memory only
database
|
void |
createTestDatabase()
Used to create the test database.
|
boolean |
dropTable(java.sql.Connection connection,
java.lang.String tableName)
This is called to delete a table from the database.
|
void |
executeSQL(java.sql.Connection connection,
java.lang.String sql)
This is used to execute a simple SQL statement on the database.
|
java.sql.PreparedStatement |
getStatement(java.sql.Connection connection,
java.lang.String sql)
This is used to create a PreparedStatement from the give SQL.
|
void |
init()
This is used to setup the database manager class, it should be called
after creating a database manager class.
|
static java.lang.String |
translateSQL(java.lang.String sql)
This will translate mysql sql into HSQLDB sql
|
closeConnection, commitTransactionConnection, createTransactionConnection, dropTable, executeSQL, executeUpdate, executeUpdate, getStatement, insertIntoTable, insertIntoTable, rollbackTransactionConnection
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
closeConnection, commitTransactionConnection, createTransactionConnection, dropTable, executeSQL, executeUpdate, executeUpdate, getStatement, insertIntoTable, insertIntoTable, rollbackTransactionConnection
public HSQLDatabase(java.lang.String host, java.lang.String username, java.lang.String password, java.lang.String database)
host
- The database hostusername
- The name of the user used to access the databasepassword
- The name of the password used to access the databasedatabase
- The name of the database to connect topublic void init() throws UnableToConnectToDatabaseException
init
in interface IDatabase
UnableToConnectToDatabaseException
public java.sql.Connection createConnection() throws java.sql.SQLException
createConnection
in interface IDatabase
java.sql.SQLException
- Thrown if their is a problem getting the connection to the
databasepublic void createTestDatabase()
public boolean dropTable(java.sql.Connection connection, java.lang.String tableName)
public java.sql.PreparedStatement getStatement(java.sql.Connection connection, java.lang.String sql) throws java.sql.SQLException
getStatement
in interface IDatabase
connection
- A connection to the databasesql
- The statements sqljava.sql.SQLException
- Thrown if their is a problem creating the statementPreparedStatement
public void closeDatabaseResources(java.sql.Connection connection, java.sql.PreparedStatement stmt, java.sql.ResultSet rs)
closeDatabaseResources
in interface IDatabase
closeDatabaseResources
in class AbstractGenericDatabase
connection
- The connection to closestmt
- The statement to closers
- The result set to closepublic static java.lang.String translateSQL(java.lang.String sql)
sql
- The mysql sqlpublic void executeSQL(java.sql.Connection connection, java.lang.String sql) throws java.sql.SQLException
executeSQL
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 databasejava.sql.SQLException
- Thrown if their is a problem talking to the database