/**
* Represents a set of tables.
- *
+ *
* @author Erik Brakkee
*/
public static interface TableSet {
* Represents a unit of work (transaction).
*
* @author Erik Brakkee
- *
- * @param <T> Type of return value.
+ *
+ * @param <T>
+ * Type of return value.
*/
public static interface JdbcUnitOfWork<T> {
/**
- * Executes statement within a transaction.
- * @param aConnection Connection.
- * @return Result of the work.
+ * Executes statement within a transaction.
+ *
+ * @param aConnection
+ * Connection.
+ * @return Result of the work.
* @throws Exception
*/
T execute(Connection aConnection) throws Exception;
}
/**
- * Operation to be executed on a set of tables for each table
- * individually.
+ * Operation to be executed on a set of tables for each table individually.
*
* @author Erik Brakkee
*/
public static interface TableSetOperation {
/**
- * Executes on a table.
- * @param aTable Table name.
+ * Executes on a table.
+ *
+ * @param aTable
+ * Table name.
* @throws Exception
*/
void execute(String aTable) throws Exception;
private IDatabaseTester dbtester;
/**
- * List of connections that were created for dbtesters.
- * This list will be closed in the {@link #stop()} method.
+ * List of connections that were created for dbtesters. This list will be
+ * closed in the {@link #stop()} method.
*/
- private List<IDatabaseConnection> connections;
-
+ private List<IDatabaseConnection> connections;
+
/**
- * Constructs the database utils.
- * Before use, {@link #start()} must be called.
- * @param aDataSource Datasource.
+ * Constructs the database utils. Before use, {@link #start()} must be
+ * called.
+ *
+ * @param aDataSource
+ * Datasource.
*/
public DatabaseUtils(DataSource aDataSource) {
dataSource = aDataSource;
dbtester = new DataSourceDatabaseTester(dataSource);
- connections = new ArrayList<IDatabaseConnection>();
+ connections = new ArrayList<IDatabaseConnection>();
}
/**
- * Starts the database utils.
+ * Starts the database utils.
*/
- public void start() {
- // Empty. No operation currently.
+ public void start() {
+ // Empty. No operation currently.
}
/**
* Stops the database utils, closing any JDBC connections that were created
- * by this utility. Note that connections obtained from the datasource directly
- * must still be closed by the user. The involved connections are only those that
- * are created by this utility.
+ * by this utility. Note that connections obtained from the datasource
+ * directly must still be closed by the user. The involved connections are
+ * only those that are created by this utility.
*/
public void stop() {
- for (IDatabaseConnection connection: connections) {
+ for (IDatabaseConnection connection : connections) {
try {
connection.close();
} catch (SQLException e) {
}
/**
- * Creates database tester.
- * @param aTables Tables to create the tester for.
- * @return Database tester.
+ * Creates database tester.
+ *
+ * @param aTables
+ * Tables to create the tester for.
+ * @return Database tester.
* @throws Exception
*/
- public IDatabaseTester createDbTester(ITableFilterSimple aTables) throws Exception {
+ public IDatabaseTester createDbTester(ITableFilterSimple aTables)
+ throws Exception {
return createDbTester(getTableNames(aTables));
}
-
+
/**
- * Creates database tester.
- * @param aTables Tables to create the tester for.
- * @return Database tester.
+ * Creates database tester.
+ *
+ * @param aTables
+ * Tables to create the tester for.
+ * @return Database tester.
* @throws Exception
*/
public IDatabaseTester createDbTester(String[] aTables) throws Exception {
}
/**
- * Executes an operation on a set of tables.
- * @param aTables Tables.
- * @param aOperation Operation.
+ * Executes an operation on a set of tables.
+ *
+ * @param aTables
+ * Tables.
+ * @param aOperation
+ * Operation.
* @throws Exception
*/
public void executeOnTables(ITableFilterSimple aTables,
}
/**
- * Cleans a number of database tables. This means deleting the content not dropping the tables.
- * This may fail in case of cyclic dependencies between the tables (current limitation).
- * @param aSelection Tables.
+ * Cleans a number of database tables. This means deleting the content not
+ * dropping the tables. This may fail in case of cyclic dependencies between
+ * the tables (current limitation).
+ *
+ * @param aSelection
+ * Tables.
* @throws Exception
*/
public void cleanDatabase(ITableFilterSimple aSelection) throws Exception {
}
/**
- * Executes a unit of work within a transaction.
- * @param <T> Result type of th ework.
- * @param aWork Unit of work.
+ * Executes a unit of work within a transaction.
+ *
+ * @param <T>
+ * Result type of th ework.
+ * @param aWork
+ * Unit of work.
* @return
* @throws Exception
*/
- public <T> T executeInTransaction(JdbcUnitOfWork<T> aWork)
- throws Exception {
+ public <T> T executeInTransaction(JdbcUnitOfWork<T> aWork) throws Exception {
Connection connection = dataSource.getConnection();
connection.setAutoCommit(false);
try {
connection.close();
}
}
-
+
/**
- * Returns table names based on a table filter.
- * @param aSelection Table filter.
- * @return Table names.
+ * Returns table names based on a table filter.
+ *
+ * @param aSelection
+ * Table filter.
+ * @return Table names.
* @throws Exception
*/
public String[] getTableNames(ITableFilterSimple aSelection)
}
/**
- * Use {@link #cleanDatabase(ITableFilterSimple)} instead.
+ * Use {@link #cleanDatabase(ITableFilterSimple)} instead.
*/
@Deprecated
public void emptyTables(final ITableFilterSimple aSelection)
}
/**
- * User {@link #cleanDatabase(ITableFilterSimple)} instead.
+ * User {@link #cleanDatabase(ITableFilterSimple)} instead.
*/
@Deprecated
public void emptyTable(String aTable) throws Exception {
}
/**
- * Drops tables. This only works if there are no cyclic dependencies between the tables.
- * @param aTables Tables to drop.
+ * Drops tables. This only works if there are no cyclic dependencies between
+ * the tables.
+ *
+ * @param aTables
+ * Tables to drop.
* @throws Exception
*/
public void dropTables(ITableFilterSimple aTables) throws Exception {
}
/**
- * Drops a table.
- * @param aTable Table to drop.
+ * Drops a table.
+ *
+ * @param aTable
+ * Table to drop.
* @throws Exception
*/
public void dropTable(final String aTable) throws Exception {
}
/**
- * Executes an update.
- * @param aConnection Connection to use.
- * @param aSql SQL update to use.
- * @param aArgs Arguments to the update.
- * @return Number of rows updated.
+ * Executes an update.
+ *
+ * @param aConnection
+ * Connection to use.
+ * @param aSql
+ * SQL update to use.
+ * @param aArgs
+ * Arguments to the update.
+ * @return Number of rows updated.
*/
public int executeUpdate(Connection aConnection, final String aSql,
final Object... aArgs) {
}
/**
- * Gets the table size.
- * @param aTable Table.
- * @return Table size.
+ * Gets the table size.
+ *
+ * @param aTable
+ * Table.
+ * @return Table size.
* @throws SQLException
*/
public int getTableSize(final String aTable) throws Exception {
}
/**
- * Counts the results in a result set.
- * @param aResultSet Resultset.
- * @return Number of rows in the set.
+ * Counts the results in a result set.
+ *
+ * @param aResultSet
+ * Resultset.
+ * @return Number of rows in the set.
* @throws SQLException
*/
public int countResultSet(ResultSet aResultSet) throws SQLException {