de.akquinet.jbosscc.needle.db.operation
Class AbstractDBOperation

java.lang.Object
  extended by de.akquinet.jbosscc.needle.db.operation.AbstractDBOperation
All Implemented Interfaces:
DBOperation
Direct Known Subclasses:
ExecuteScriptOperation, HSQLDeleteOperation

public abstract class AbstractDBOperation
extends Object
implements DBOperation

An abstract implementation of DBOperation with common jdbc operations.


Constructor Summary
AbstractDBOperation(JdbcConfiguration jdbcConfiguration)
           
 
Method Summary
protected  void closeConnection()
          Close the connection to the database.
protected  void commit()
          Commits the current transaction.
protected  void executeScript(String filename, Statement statement)
          Execute the given sql script.
protected  Connection getConnection()
          Returns the sql connection object.
protected  List<String> getTableNames(Connection connection)
          Returns the names of all tables in the database by using DatabaseMetaData.
protected  void openConnection()
          Establish a connection to the given database.
protected  void rollback()
          Revoke the current transaction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.akquinet.jbosscc.needle.db.operation.DBOperation
setUpOperation, tearDownOperation
 

Constructor Detail

AbstractDBOperation

public AbstractDBOperation(JdbcConfiguration jdbcConfiguration)
Method Detail

openConnection

protected void openConnection()
                       throws SQLException
Establish a connection to the given database.

Throws:
SQLException - if a database access error occurs

closeConnection

protected void closeConnection()
                        throws SQLException
Close the connection to the database.

Throws:
SQLException - if a database access error occurs

commit

protected void commit()
               throws SQLException
Commits the current transaction.

Throws:
SQLException - if a database access error occurs

rollback

protected void rollback()
                 throws SQLException
Revoke the current transaction.

Throws:
SQLException - if a database access error occurs

getTableNames

protected List<String> getTableNames(Connection connection)
                              throws SQLException
Returns the names of all tables in the database by using DatabaseMetaData.

Parameters:
connection - the jdbc connection object
Returns:
a List of all table names
Throws:
SQLException - if a database access error occurs

executeScript

protected void executeScript(String filename,
                             Statement statement)
                      throws SQLException
Execute the given sql script.

Parameters:
filename - the filename of the sql script
statement - the Statement to be used for executing a SQL statement.
Throws:
SQLException - if a database access error occurs

getConnection

protected Connection getConnection()
                            throws SQLException
Returns the sql connection object. If there is no connection a new connection is established.

Returns:
the sql connection object
Throws:
SQLException - if a database access error occurs


Copyright © 2013 akquinet AG. All Rights Reserved.