Package org.dbunit.ext.h2

Examples of org.dbunit.ext.h2.H2Connection


   * @param xmlFilePaths 符合Spring Resource路径格式的文件列表.
   */
  private static void execute(DatabaseOperation operation, DataSource dataSource, String... xmlFilePaths)
      throws DatabaseUnitException, SQLException {
    //注意这里HardCode了使用H2的Connetion
    IDatabaseConnection connection = new H2Connection(dataSource.getConnection(), null);

    for (String xmlPath : xmlFilePaths) {
      try {
        InputStream input = resourceLoader.getResource(xmlPath).getInputStream();
        IDataSet dataSet = new FlatXmlDataSetBuilder().setColumnSensing(true).build(input);
        operation.execute(connection, dataSet);
      } catch (IOException e) {
        logger.warn(xmlPath + " file not found", e);
      }finally{
        connection.close();
      }
    }
  }
View Full Code Here


   *
   * @param xmlFilePaths 符合Spring Resource路径格式的文件列表.
   */
  private static void execute(DatabaseOperation operation, DataSource h2DataSource, String... xmlFilePaths)
      throws DatabaseUnitException, SQLException {
    IDatabaseConnection connection = new H2Connection(h2DataSource.getConnection(), "");
    for (String xmlPath : xmlFilePaths) {
      try {
        InputStream input = resourceLoader.getResource(xmlPath).getInputStream();
        IDataSet dataSet = new FlatXmlDataSetBuilder().setColumnSensing(true).build(input);
        operation.execute(connection, dataSet);
View Full Code Here

    protected static IDatabaseConnection getConnection(DataSource dataSource) throws DatabaseUnitException,
            SQLException {
        Connection connection = dataSource.getConnection();
        String jdbcUrl = connection.getMetaData().getURL();
        if (StringUtils.contains(jdbcUrl, ":h2:")) {
            return new H2Connection(connection, null);
        } else if (StringUtils.contains(jdbcUrl, ":mysql:")) {
            return new MySqlConnection(connection, null);
        } else if (StringUtils.contains(jdbcUrl, ":oracle:")) {
            return new OracleConnection(connection, null);
        } else {
View Full Code Here

                }
            }
            IDatabaseConnection connection = new DatabaseConnection(DriverManager.getConnection(provider.getUrl(), username, password));
            DatabaseConfig config = connection.getConfig();
            if (provider.getUrl().startsWith("jdbc:h2")) {
                config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new H2DataTypeFactory());
            } else if (provider.getUrl().startsWith("jdbc:hsql")) {
                config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new HsqldbDataTypeFactory());
            } else if (provider.getUrl().startsWith("jdbc:mysql")) {
                config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new MySqlDataTypeFactory());
            }
View Full Code Here

    switch (this.emUtil.getDbType()) {
    case DERBY:
      dataTypeFactory = new DefaultDataTypeFactory();
      break;
    case H2:
      dataTypeFactory = new H2DataTypeFactory();
      break;
    case MYSQL:
      dataTypeFactory = new MySqlDataTypeFactory();
      metadataHandler = new MySqlMetadataHandler();
      break;
View Full Code Here

    switch (this.emUtil.getDbType()) {
    case DERBY:
      dataTypeFactory = new DefaultDataTypeFactory();
      break;
    case H2:
      dataTypeFactory = new H2DataTypeFactory();
      break;
    case MYSQL:
      dataTypeFactory = new MySqlDataTypeFactory();
      metadataHandler = new MySqlMetadataHandler();
      break;
View Full Code Here

    switch (this.connUtil.getDbType()) {
    case DERBY:
      dataTypeFactory = new DefaultDataTypeFactory();
      break;
    case H2:
      dataTypeFactory = new H2DataTypeFactory();
      break;
    case MYSQL:
      dataTypeFactory = new MySqlDataTypeFactory();
      metadataHandler = new MySqlMetadataHandler();
      break;
View Full Code Here

    switch (this.connUtil.getDbType()) {
    case DERBY:
      dataTypeFactory = new DefaultDataTypeFactory();
      break;
    case H2:
      dataTypeFactory = new H2DataTypeFactory();
      break;
    case MYSQL:
      dataTypeFactory = new MySqlDataTypeFactory();
      metadataHandler = new MySqlMetadataHandler();
      break;
View Full Code Here

            DatabaseConnection dbConn =
                    new DatabaseConnection(dataSource.getConnection());
            // NB: Specific to H2
            dbConn.getConfig().setProperty(
                    DatabaseConfig.PROPERTY_DATATYPE_FACTORY,
                    new H2DataTypeFactory());
            return dbConn;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

            DatabaseConnection dbConn =
                    new DatabaseConnection(dataSource.getConnection());
            // NB: Specific to H2
            dbConn.getConfig().setProperty(
                    DatabaseConfig.PROPERTY_DATATYPE_FACTORY,
                    new H2DataTypeFactory());
            return dbConn;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

TOP

Related Classes of org.dbunit.ext.h2.H2Connection

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.