Package org.dbunit.database

Examples of org.dbunit.database.DatabaseConnection


        Connection jdbcConnection = DriverManager.getConnection(
                "jdbc:mysql://localhost:3306/pm", "pm", "pm");

        // connection (+ schema � utiliser �ventuellement)
        return new DatabaseConnection(jdbcConnection);

    }
View Full Code Here


    Connection jdbcConnection = DriverManager.getConnection(
        "jdbc:mysql://localhost:3306/pm_tu", "pm", "pm");

    // connection (+ schema à utiliser éventuellement)
       
        IDatabaseConnection databaseConnection = new DatabaseConnection( jdbcConnection );
       
      DatabaseConfig config = databaseConnection.getConfig();
     
      config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new HsqlDataTypeFactory());
      
       
      return databaseConnection;  
View Full Code Here

            // database connection
            Class driverClass = Class.forName("com.mysql.jdbc.Driver");

        Connection jdbcConnection = DriverManager.getConnection(
            "jdbc:mysql://localhost:3306/pmtu", "pm", "pm");
            IDatabaseConnection connection = new DatabaseConnection(jdbcConnection);

            // write DTD file
            FlatDtdDataSet.write(connection.createDataSet(),
                    new FileOutputStream("pm.dtd"));
        }
View Full Code Here

    Connection jdbcConnection = DriverManager.getConnection(
        "jdbc:mysql://localhost:3306/pm_tu", "pm", "pm");

    // connection (+ schema à utiliser éventuellement)
    return new DatabaseConnection(jdbcConnection);

  }
View Full Code Here

  }
 
  @Override
  public IDatabaseConnection create() {
    try {
      IDatabaseConnection dbUnitConn = new DatabaseConnection(this.getConnection());
      return dbUnitConn;
    } catch (DatabaseUnitException e) {
      throw new IllegalStateException(
          "It's not possible to create a DbUnit connection: "
              + e.getMessage(), e);
View Full Code Here

  }

  @Override
  public IDatabaseConnection create() {
    try {
      IDatabaseConnection dbUnitConn = new DatabaseConnection(getConnection());
      dbUnitConn.getConfig().setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new PostgresqlDataTypeFactory());
      return dbUnitConn;
    } catch (DatabaseUnitException e) {
      throw new IllegalStateException(
          "It's not possible to create a PostgreSql DbUnit connection: "
              + e.getMessage(), e);
View Full Code Here

         DataSource datasource = ((DataSource) getInitialContext().lookup(datasourceJndiName));

         // Get a JDBC connection from JNDI datasource
         Connection con = datasource.getConnection();
         IDatabaseConnection dbUnitCon = new DatabaseConnection(con);
         editConfig(dbUnitCon.getConfig());
         return dbUnitCon;
      }
      catch (Exception ex)
      {
         throw new RuntimeException(ex);
View Full Code Here

        "name varchar(100), address varchar(100), city varchar(100), country varchar(100), " +
        "age smallint)");
    Connection con = DataSourceUtils.getConnection(ds);
    IDatabaseConnection dbUnitCon = null;
    try {
      dbUnitCon = new DatabaseConnection(con);
    } catch (DatabaseUnitException e) {
      System.out.println(e);
    }
    dbUnitCon.getConfig().setProperty(DatabaseConfig.FEATURE_BATCHED_STATEMENTS, Boolean.TRUE);
    dbUnitCon.getConfig().setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new MySqlDataTypeFactory());
View Full Code Here

        "age smallint)");
    // Test data
    Connection con = DataSourceUtils.getConnection(ds);
    IDatabaseConnection dbUnitCon = null;
    try {
      dbUnitCon = new DatabaseConnection(con);
    } catch (DatabaseUnitException e) {
      System.out.println(e);
    }
    dbUnitCon.getConfig().setProperty(DatabaseConfig.FEATURE_BATCHED_STATEMENTS, Boolean.TRUE);
    dbUnitCon.getConfig().setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new PostgresqlDataTypeFactory());
View Full Code Here

    }

    private IDatabaseConnection getDBUnitConnection(Connection c)
            throws DatabaseUnitException
            {
        IDatabaseConnection conn = new DatabaseConnection(c);
        DatabaseConfig config = conn.getConfig();
        config.setFeature("http://www.dbunit.org/features/qualifiedTableNames",
                true);
        config.setProperty("http://www.dbunit.org/properties/tableType",
                TABLE_TYPES);
        return conn;
View Full Code Here

TOP

Related Classes of org.dbunit.database.DatabaseConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.