Package org.dbunit.database
Class DatabaseConnection
java.lang.Object
org.dbunit.database.AbstractDatabaseConnection
org.dbunit.database.DatabaseConnection
- All Implemented Interfaces:
IDatabaseConnection
- Direct Known Subclasses:
Db2Connection,H2Connection,HsqldbConnection,MckoiConnection,MsSqlConnection,MySqlConnection,OracleConnection
This class adapts a JDBC
Connection to a
IDatabaseConnection.- Since:
- Feb 21, 2002
- Version:
- $Revision$
- Author:
- Manuel Laflamme
-
Constructor Summary
ConstructorsConstructorDescriptionDatabaseConnection(Connection connection) Creates a newDatabaseConnection.DatabaseConnection(Connection connection, String schema) Creates a newDatabaseConnectionusing a specific schema.DatabaseConnection(Connection connection, String schema, boolean validate) Creates a newDatabaseConnectionusing a specific schema. -
Method Summary
Methods inherited from class org.dbunit.database.AbstractDatabaseConnection
createDataSet, createDataSet, createQueryTable, createTable, createTable, getConfig, getRowCount, getRowCount, getStatementFactoryMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.dbunit.database.IDatabaseConnection
createDataSet, createDataSet, createQueryTable, createTable, createTable, getConfig, getRowCount, getRowCount, getStatementFactory
-
Constructor Details
-
DatabaseConnection
Creates a newDatabaseConnection.- Parameters:
connection- the adapted JDBC connection- Throws:
DatabaseUnitException
-
DatabaseConnection
Creates a newDatabaseConnectionusing a specific schema.- Parameters:
connection- the adapted JDBC connectionschema- the database schema. Note that the schema name is case sensitive. This is necessary because schemas with the same name but different case can coexist on one database.
Here an example that creates two users/schemas for oracle where only the case is different:
create user dbunittest identified by dbunittest; create user "dbunittest" identified by "dbunittest";The first one creates the "default" user where everything is interpreted by oracle in uppercase. The second one is completely lowercase because of the quotes.- Throws:
DatabaseUnitException
-
DatabaseConnection
public DatabaseConnection(Connection connection, String schema, boolean validate) throws DatabaseUnitException Creates a newDatabaseConnectionusing a specific schema.- Parameters:
connection- the adapted JDBC connectionschema- the database schema. Note that the schema name is case sensitive. This is necessary because schemas with the same name but different case can coexist on one database.
Here an example that creates two users/schemas for oracle where only the case is different:
create user dbunittest identified by dbunittest; create user "dbunittest" identified by "dbunittest";The first one creates the "default" user where everything is interpreted by oracle in uppercase. The second one is completely lowercase because of the quotes.validate- Iftruean exception is thrown when the given schema does not exist according to the DatabaseMetaData. Iffalsethe validation will only print a warning if the schema was not found.- Throws:
DatabaseUnitException- If thevalidateparameter istrueand the validation of the given connection/schema was not successful (added with 2.3.0). This can happen if the given schema does not exist or if the jdbc driver does not implement the metaData.getSchemas() method properly.- Since:
- 2.3.0
-
-
Method Details
-
getConnection
Description copied from interface:IDatabaseConnectionReturns a JDBC database connection.- Specified by:
getConnectionin interfaceIDatabaseConnection- Throws:
SQLException
-
getSchema
Description copied from interface:IDatabaseConnectionReturns the database schema name.- Specified by:
getSchemain interfaceIDatabaseConnection
-
close
Description copied from interface:IDatabaseConnectionClose this connection.- Specified by:
closein interfaceIDatabaseConnection- Throws:
SQLException
-
toString
- Overrides:
toStringin classAbstractDatabaseConnection
-