Package org.dbunit.database
Interface IDatabaseConnection
- All Known Implementing Classes:
AbstractDatabaseConnection,DatabaseConnection,DatabaseDataSourceConnection,Db2Connection,H2Connection,HsqldbConnection,MckoiConnection,MsSqlConnection,MySqlConnection,OracleConnection
public interface IDatabaseConnection
This interface represents a connection to a specific database.
- Since:
- Mar 6, 2002
- Version:
- $Revision$
- Author:
- Manuel Laflamme
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close this connection.Creates a dataset corresponding to the entire database.createDataSet(String[] tableNames) Creates a dataset containing only the specified tables from the database.createQueryTable(String tableName, String sql) Creates a table with the result of the specified SQL statement.createTable(String tableName) Creates a table with the result of aselect * from tableNameSQL statement.createTable(String tableName, PreparedStatement preparedStatement) Creates a table using the given PreparedStatement to retrieve a ResultSet.Returns this connection database configurationReturns a JDBC database connection.intgetRowCount(String tableName) Returns the specified table row count.intgetRowCount(String tableName, String whereClause) Returns the specified table row count according specified where clause.Returns the database schema name.Deprecated.
-
Method Details
-
getConnection
Returns a JDBC database connection.- Returns:
- the underlying JDBC connection.
- Throws:
SQLException- if a database access error occurs.
-
getSchema
String getSchema()Returns the database schema name.- Returns:
- the schema name, or
nullif none is set.
-
close
Close this connection.- Throws:
SQLException- if a database access error occurs.
-
createDataSet
Creates a dataset corresponding to the entire database.- Returns:
- the new dataset.
- Throws:
SQLException- if a database access error occurs.
-
createDataSet
Creates a dataset containing only the specified tables from the database.- Parameters:
tableNames- The tables for which a dataset shall be created- Returns:
- The new dataset
- Throws:
SQLException- if a database access error occurs.DataSetException- if a table intableNamesdoes not exist in the database.
-
createQueryTable
Creates a table with the result of the specified SQL statement. The table can be the result of a join statement.- Parameters:
tableName- The name to be returned byITableMetaData.getTableName().sql- The SQLSELECTstatement- Returns:
- The new table
- Throws:
DataSetException- if an error occurs building the table's metadata.SQLException- if a database access error occurs.
-
createTable
ITable createTable(String tableName, PreparedStatement preparedStatement) throws DataSetException, SQLException Creates a table using the given PreparedStatement to retrieve a ResultSet.- Parameters:
tableName- The name to be returned byITableMetaData.getTableName().preparedStatement- The statement to be executed as query- Returns:
- The new table
- Throws:
DataSetException- if an error occurs building the table's metadata.SQLException- if a database access error occurs.- Since:
- 2.4.4
-
createTable
Creates a table with the result of aselect * from tableNameSQL statement.- Parameters:
tableName- The name of the database table to be queried which is also returned byITableMetaData.getTableName().- Returns:
- The new table.
- Throws:
DataSetException- if an error occurs building the table's metadata.SQLException- if a database access error occurs.
-
getRowCount
Returns the specified table row count.- Parameters:
tableName- the table name- Returns:
- the row count
- Throws:
SQLException- if a database access error occurs.
-
getRowCount
Returns the specified table row count according specified where clause.- Parameters:
tableName- the table namewhereClause- the where clause- Returns:
- the row count
- Throws:
SQLException- if a database access error occurs.
-
getConfig
DatabaseConfig getConfig()Returns this connection database configuration- Returns:
- this connection's
DatabaseConfig.
-
getStatementFactory
IStatementFactory getStatementFactory()Deprecated.UsegetConfig()Returns the statement factory configured on this connection.- Returns:
- this connection's
IStatementFactory.
-
getConfig()