|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.wamblee.test.persistence.DatabaseUtils
public class DatabaseUtils
Database utilities is a simple support class for common tasks in working with databases.
| Nested Class Summary | |
|---|---|
static interface |
DatabaseUtils.JdbcUnitOfWork<T>
Represents a unit of work (transaction). |
static interface |
DatabaseUtils.TableSet
Represents a set of tables. |
static interface |
DatabaseUtils.TableSetOperation
Operation to be executed on a set of tables for each table individually. |
| Constructor Summary | |
|---|---|
DatabaseUtils(javax.sql.DataSource aDataSource)
Constructs the database utils. |
|
| Method Summary | ||
|---|---|---|
void |
cleanDatabase(org.dbunit.dataset.filter.ITableFilterSimple aSelection)
Cleans a number of database tables. |
|
int |
countResultSet(java.sql.ResultSet aResultSet)
Counts the results in a result set. |
|
org.dbunit.IDatabaseTester |
createDbTester(org.dbunit.dataset.filter.ITableFilterSimple aTables)
Creates database tester. |
|
org.dbunit.IDatabaseTester |
createDbTester(java.lang.String[] aTables)
Creates database tester. |
|
void |
dropTable(java.lang.String aTable)
Drops a table. |
|
void |
dropTables(org.dbunit.dataset.filter.ITableFilterSimple aTables)
Drops tables. |
|
void |
emptyTable(java.lang.String aTable)
Deprecated. |
|
void |
emptyTables(org.dbunit.dataset.filter.ITableFilterSimple aSelection)
Deprecated. |
|
|
executeInTransaction(DatabaseUtils.JdbcUnitOfWork<T> aWork)
Executes a unit of work within a transaction. |
|
void |
executeOnTables(org.dbunit.dataset.filter.ITableFilterSimple aTables,
DatabaseUtils.TableSetOperation aOperation)
Executes an operation on a set of tables. |
|
java.sql.ResultSet |
executeQuery(java.sql.Connection aConnection,
java.lang.String aSql)
Executes an SQL query. |
|
java.sql.ResultSet |
executeQuery(java.sql.Connection aConnection,
java.lang.String aSql,
java.lang.Object aArg)
Executes a query with a single argument. |
|
java.sql.ResultSet |
executeQuery(java.sql.Connection aConnection,
java.lang.String aSql,
java.lang.Object[] aArgs)
Executes a query. |
|
int |
executeSql(java.lang.String aSql)
Executes an SQL statement within a transaction. |
|
int |
executeSql(java.lang.String aSql,
java.lang.Object aArg)
Executes an SQL statement within a transaction. |
|
int |
executeSql(java.lang.String aSql,
java.lang.Object[] aArgs)
Executes an sql statement. |
|
int |
executeUpdate(java.sql.Connection aConnection,
java.lang.String aSql,
java.lang.Object... aArgs)
Executes an update. |
|
java.lang.String[] |
getTableNames(org.dbunit.dataset.filter.ITableFilterSimple aSelection)
Returns table names based on a table filter. |
|
int |
getTableSize(java.lang.String aTable)
Gets the table size. |
|
void |
start()
Starts the database utils. |
|
void |
stop()
Stops the database utils, closing any JDBC connections that were created by this utility. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DatabaseUtils(javax.sql.DataSource aDataSource)
start() must be called.
aDataSource - Datasource.| Method Detail |
|---|
public void start()
public void stop()
public org.dbunit.IDatabaseTester createDbTester(org.dbunit.dataset.filter.ITableFilterSimple aTables)
throws java.lang.Exception
aTables - Tables to create the tester for.
java.lang.Exception
public org.dbunit.IDatabaseTester createDbTester(java.lang.String[] aTables)
throws java.lang.Exception
aTables - Tables to create the tester for.
java.lang.Exception
public void executeOnTables(org.dbunit.dataset.filter.ITableFilterSimple aTables,
DatabaseUtils.TableSetOperation aOperation)
throws java.lang.Exception
aTables - Tables.aOperation - Operation.
java.lang.Exception
public void cleanDatabase(org.dbunit.dataset.filter.ITableFilterSimple aSelection)
throws java.lang.Exception
aSelection - Tables.
java.lang.Exception
public <T> T executeInTransaction(DatabaseUtils.JdbcUnitOfWork<T> aWork)
throws java.lang.Exception
T - Result type of th ework.aWork - Unit of work.
java.lang.Exception
public java.lang.String[] getTableNames(org.dbunit.dataset.filter.ITableFilterSimple aSelection)
throws java.lang.Exception
aSelection - Table filter.
java.lang.Exception
@Deprecated
public void emptyTables(org.dbunit.dataset.filter.ITableFilterSimple aSelection)
throws java.lang.Exception
cleanDatabase(ITableFilterSimple) instead.
java.lang.Exception
@Deprecated
public void emptyTable(java.lang.String aTable)
throws java.lang.Exception
cleanDatabase(ITableFilterSimple) instead.
java.lang.Exception
public void dropTables(org.dbunit.dataset.filter.ITableFilterSimple aTables)
throws java.lang.Exception
aTables - Tables to drop.
java.lang.Exception
public void dropTable(java.lang.String aTable)
throws java.lang.Exception
aTable - Table to drop.
java.lang.Exception
public int executeSql(java.lang.String aSql)
throws java.lang.Exception
aSql - SQL statement.
java.lang.Exception
public int executeSql(java.lang.String aSql,
java.lang.Object aArg)
throws java.lang.Exception
setPreparedParam(int, PreparedStatement, Object)for details on
supported argument types.
aSql - SQL statement.aArg - Argument of the sql statement.
java.lang.Exception
public int executeSql(java.lang.String aSql,
java.lang.Object[] aArgs)
throws java.lang.Exception
setPreparedParam(int, PreparedStatement, Object)for details on
supported argument types.
aSql - SQL query to execute.aArgs - Arguments.
java.lang.Exception
public java.sql.ResultSet executeQuery(java.sql.Connection aConnection,
java.lang.String aSql)
aSql - Query to execute.
public java.sql.ResultSet executeQuery(java.sql.Connection aConnection,
java.lang.String aSql,
java.lang.Object aArg)
setPreparedParam(int, PreparedStatement, Object)for details on
supported argument types.
aSql - Query.aArg - Argument.
public java.sql.ResultSet executeQuery(java.sql.Connection aConnection,
java.lang.String aSql,
java.lang.Object[] aArgs)
setPreparedParam(int, PreparedStatement, Object)for details on
supported argument types.
aSql - Sql query.aArgs - Arguments to the query.
public int executeUpdate(java.sql.Connection aConnection,
java.lang.String aSql,
java.lang.Object... aArgs)
aConnection - Connection to use.aSql - SQL update to use.aArgs - Arguments to the update.
public int getTableSize(java.lang.String aTable)
throws java.lang.Exception
aTable - Table.
java.sql.SQLException
java.lang.Exception
public int countResultSet(java.sql.ResultSet aResultSet)
throws java.sql.SQLException
aResultSet - Resultset.
java.sql.SQLException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||