Package org.dbunit.database
Class DatabaseDataSourceConnection
java.lang.Object
org.dbunit.database.AbstractDatabaseConnection
org.dbunit.database.DatabaseDataSourceConnection
- All Implemented Interfaces:
IDatabaseConnection
public class DatabaseDataSourceConnection
extends AbstractDatabaseConnection
implements IDatabaseConnection
This class adapts a JDBC
DataSource to a
IDatabaseConnection.- Since:
- Mar 8, 2002
- Version:
- $Revision$
- Author:
- Manuel Laflamme
-
Constructor Summary
ConstructorsConstructorDescriptionDatabaseDataSourceConnection(InitialContext context, String jndiName) Creates a connection using the data source bound at the given JNDI name.DatabaseDataSourceConnection(InitialContext context, String jndiName, String schema) Creates a connection using the data source bound at the given JNDI name, in the given schema.DatabaseDataSourceConnection(InitialContext context, String jndiName, String user, String password) Creates a connection using the data source bound at the given JNDI name, authenticating with the given credentials.DatabaseDataSourceConnection(InitialContext context, String jndiName, String schema, String user, String password) Creates a connection using the data source bound at the given JNDI name, in the given schema, authenticating with the given credentials.DatabaseDataSourceConnection(DataSource dataSource) Creates a connection using the given data source.DatabaseDataSourceConnection(DataSource dataSource, String schema) Creates a connection using the given data source, in the given schema.DatabaseDataSourceConnection(DataSource dataSource, String user, String password) Creates a connection using the given data source, authenticating with the given credentials.DatabaseDataSourceConnection(DataSource dataSource, String schema, String user, String password) Creates a connection using the given data source, in the given schema, authenticating with the given credentials. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close this connection.Returns a JDBC database connection.Returns the database schema name.Methods inherited from class org.dbunit.database.AbstractDatabaseConnection
createDataSet, createDataSet, createQueryTable, createTable, createTable, getConfig, getRowCount, getRowCount, getStatementFactory, toStringMethods 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
-
DatabaseDataSourceConnection
public DatabaseDataSourceConnection(InitialContext context, String jndiName, String schema) throws NamingException, SQLException Creates a connection using the data source bound at the given JNDI name, in the given schema.- Parameters:
context- the JNDI context to look up the data source in.jndiName- the JNDI name the data source is bound at.schema- the database schema.- Throws:
NamingException- if the JNDI lookup fails.SQLException- if a database access error occurs.
-
DatabaseDataSourceConnection
public DatabaseDataSourceConnection(InitialContext context, String jndiName, String schema, String user, String password) throws NamingException, SQLException Creates a connection using the data source bound at the given JNDI name, in the given schema, authenticating with the given credentials.- Parameters:
context- the JNDI context to look up the data source in.jndiName- the JNDI name the data source is bound at.schema- the database schema.user- the database user.password- the database password.- Throws:
NamingException- if the JNDI lookup fails.SQLException- if a database access error occurs.
-
DatabaseDataSourceConnection
public DatabaseDataSourceConnection(InitialContext context, String jndiName) throws NamingException, SQLException Creates a connection using the data source bound at the given JNDI name.- Parameters:
context- the JNDI context to look up the data source in.jndiName- the JNDI name the data source is bound at.- Throws:
NamingException- if the JNDI lookup fails.SQLException- if a database access error occurs.
-
DatabaseDataSourceConnection
public DatabaseDataSourceConnection(InitialContext context, String jndiName, String user, String password) throws NamingException, SQLException Creates a connection using the data source bound at the given JNDI name, authenticating with the given credentials.- Parameters:
context- the JNDI context to look up the data source in.jndiName- the JNDI name the data source is bound at.user- the database user.password- the database password.- Throws:
NamingException- if the JNDI lookup fails.SQLException- if a database access error occurs.
-
DatabaseDataSourceConnection
Creates a connection using the given data source.- Parameters:
dataSource- the data source to adapt.- Throws:
SQLException- if a database access error occurs.
-
DatabaseDataSourceConnection
public DatabaseDataSourceConnection(DataSource dataSource, String user, String password) throws SQLException Creates a connection using the given data source, authenticating with the given credentials.- Parameters:
dataSource- the data source to adapt.user- the database user.password- the database password.- Throws:
SQLException- if a database access error occurs.
-
DatabaseDataSourceConnection
Creates a connection using the given data source, in the given schema.- Parameters:
dataSource- the data source to adapt.schema- the database schema.- Throws:
SQLException- if a database access error occurs.
-
DatabaseDataSourceConnection
public DatabaseDataSourceConnection(DataSource dataSource, String schema, String user, String password) throws SQLException Creates a connection using the given data source, in the given schema, authenticating with the given credentials.- Parameters:
dataSource- the data source to adapt.schema- the database schema.user- the database user.password- the database password.- Throws:
SQLException- if a database access error occurs.
-
-
Method Details
-
getConnection
Description copied from interface:IDatabaseConnectionReturns a JDBC database connection.- Specified by:
getConnectionin interfaceIDatabaseConnection- Returns:
- the underlying JDBC connection.
- Throws:
SQLException- if a database access error occurs.
-
getSchema
Description copied from interface:IDatabaseConnectionReturns the database schema name.- Specified by:
getSchemain interfaceIDatabaseConnection- Returns:
- the schema name, or
nullif none is set.
-
close
Description copied from interface:IDatabaseConnectionClose this connection.- Specified by:
closein interfaceIDatabaseConnection- Throws:
SQLException- if a database access error occurs.
-