Package org.dbunit

Class JdbcDatabaseTester

All Implemented Interfaces:
IDatabaseTester
Direct Known Subclasses:
PropertiesBasedJdbcDatabaseTester

public class JdbcDatabaseTester extends AbstractDatabaseTester
DatabaseTester that uses JDBC's Driver Manager to create connections.
Since:
2.2
Version:
$Revision$
Author:
Andres Almiray (aalmiray@users.sourceforge.net), Felipe Leme (dbunit@felipeal.net)
  • Constructor Details

    • JdbcDatabaseTester

      public JdbcDatabaseTester(String driverClass, String connectionUrl) throws ClassNotFoundException
      Creates a new JdbcDatabaseTester with the specified properties.
      Username and Password are set to null.
      Parameters:
      driverClass - the classname of the JDBC driver to use
      connectionUrl - the connection url
      Throws:
      ClassNotFoundException - If the given driverClass was not found
    • JdbcDatabaseTester

      public JdbcDatabaseTester(String driverClass, String connectionUrl, String username, String password) throws ClassNotFoundException
      Creates a new JdbcDatabaseTester with the specified properties.
      Parameters:
      driverClass - the classname of the JDBC driver to use
      connectionUrl - the connection url
      username - a username that can has access to the database
      password - the user's password
      Throws:
      ClassNotFoundException - If the given driverClass was not found
    • JdbcDatabaseTester

      public JdbcDatabaseTester(String driverClass, String connectionUrl, String username, String password, String schema) throws ClassNotFoundException
      Creates a new JdbcDatabaseTester with the specified properties.
      Parameters:
      driverClass - the classname of the JDBC driver to use
      connectionUrl - the connection url
      username - a username that can has access to the database - can be null
      password - the user's password - can be null
      schema - the database schema to be tested - can be null
      Throws:
      ClassNotFoundException - If the given driverClass was not found
      Since:
      2.4.3
    • JdbcDatabaseTester

      public JdbcDatabaseTester(String driverClass, String connectionUrl, String username, String password, String schema, CachingConnectionProvider connectionProvider) throws ClassNotFoundException
      Creates a new JdbcDatabaseTester with the specified properties, reusing one IDatabaseConnection across calls via the given CachingConnectionProvider instead of creating a new one on every call.
      Share the same connectionProvider instance across the testers created for each test to get reuse across test methods; pair it with IOperationListener.NO_OP_OPERATION_LISTENER (or an equivalent non-closing listener) so the cached connection is not closed after every AbstractDatabaseTester.onSetup()/AbstractDatabaseTester.onTearDown() call.
      Parameters:
      driverClass - the classname of the JDBC driver to use
      connectionUrl - the connection url
      username - a username that can has access to the database - can be null
      password - the user's password - can be null
      schema - the database schema to be tested - can be null
      connectionProvider - caches and validates the connection across calls - can be null, in which case a new connection is created on every call as before
      Throws:
      ClassNotFoundException - If the given driverClass was not found
      Since:
      3.4.0
  • Method Details