Package org.dbunit.database

Examples of org.dbunit.database.DatabaseConfig


    // DatabaseOperation class

    public void execute(IDatabaseConnection connection, IDataSet dataSet)
            throws DatabaseUnitException, SQLException
    {
        DatabaseConfig databaseConfig = connection.getConfig();
        IStatementFactory factory = (IStatementFactory)databaseConfig.getProperty(
                DatabaseConfig.PROPERTY_STATEMENT_FACTORY);

        // for each table
        ITableIterator iterator = iterator(dataSet);
        while (iterator.next())
View Full Code Here


            throw new SQLException("No suitable Driver for " + url);
        }
        conn.setAutoCommit(true);

        IDatabaseConnection connection = new DatabaseConnection(conn, schema);
        DatabaseConfig config = connection.getConfig();
        config.setFeature(DatabaseConfig.FEATURE_BATCHED_STATEMENTS, supportBatchStatement);
        config.setFeature(DatabaseConfig.FEATURE_QUALIFIED_TABLE_NAMES, useQualifiedTableNames);
        config.setFeature(DatabaseConfig.FEATURE_DATATYPE_WARNING, datatypeWarning);
        config.setProperty(DatabaseConfig.PROPERTY_ESCAPE_PATTERN, escapePattern);
        config.setProperty(DatabaseConfig.PROPERTY_RESULTSET_TABLE_FACTORY,
                new ForwardOnlyResultSetTableFactory());

        // Setup data type factory
        try
        {
            IDataTypeFactory dataTypeFactory = (IDataTypeFactory)Class.forName(
                    this.dataTypeFactory).newInstance();
            config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, dataTypeFactory);
        }
        catch (ClassNotFoundException e)
        {
            throw new BuildException("Class Not Found: DataType factory "
                    + driver + " could not be loaded", e, location);
View Full Code Here

    }

    private boolean hasIdentityColumn(ITableMetaData metaData, IDatabaseConnection connection)
            throws DataSetException
    {
        DatabaseConfig config = connection.getConfig();
        IColumnFilter identityFilter = (IColumnFilter)config.getProperty(
                PROPERTY_IDENTITY_COLUMN_FILTER);
        if (identityFilter == null)
        {
            identityFilter = DEFAULT_IDENTITY_FILTER;
        }
View Full Code Here

      assertEquals("Initial value is not as expected", initialValue, expectedInitialValue);
    }

    assertFalse("Unable to test if new value is same as intial value", newValue.equals(initialValue));
    this.configBeanWrapper.setPropertyValue(propertyName, newValue);
    DatabaseConfig appliedConfig = new DatabaseConfig();
    this.configBean.apply(appliedConfig);

    assertEquals("Did not replace " + propertyName + " value", newValue,
        appliedConfig.getProperty(databaseConfigProperty));

  }
View Full Code Here

*/
public static DatabaseConnection getDatabaseConnection(Connection connection) {
  DatabaseConnection databaseConnection = null;
  try {
    databaseConnection= new DatabaseConnection(connection);
    DatabaseConfig config = databaseConnection.getConfig();
    //数据库为mysql
    if ("MySQL".equalsIgnoreCase(connection.getMetaData()
        .getDatabaseProductName())) {
      config.setProperty(DatabaseConfig.PROPERTY_METADATA_HANDLER,
          new MySqlMetadataHandler());
      config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY,
          new MySqlDataTypeFactory());
    } //else if ("Oracle".equalsIgnoreCase(connection.getMetaData()
//        .getDatabaseProductName())) {
//      config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY,
//          new Oracle10DataTypeFactory());
View Full Code Here

    }

    private void openConnection() throws Exception {
        connection = new DatabaseConnection(datasource.getConnection());
        if (database == Database.hsql) {
            DatabaseConfig config = connection.getConfig();
            config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY,
                    new HsqldbDataTypeFactory());
        }
    }
View Full Code Here

            final IDataSet dataSet = loadDataSet(source);
            final IDatabaseConnection connection = new DatabaseDataSourceConnection(
                    ((SQLDatabase)database).getDataSource());
            final Boolean qualifiedTableNames = source.getQualifiedTableNames();
            if (qualifiedTableNames != null) {
                final DatabaseConfig config = connection.getConfig();
                config.setProperty(
                        DatabaseConfig.FEATURE_QUALIFIED_TABLE_NAMES,
                        source.getQualifiedTableNames());
            }
            try {
                DatabaseOperation.INSERT.execute(connection, dataSet);
View Full Code Here

    IDatabaseConnection dbconn;
    DatabaseMetaData databaseMetaData = this.getConnection().getMetaData();

    // oracle schema name is the user name
    dbconn = new OracleConnection(this.getConnection(), databaseMetaData.getUserName());
    DatabaseConfig config = dbconn.getConfig();
    // oracle 10g
    config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new Oracle10DataTypeFactory());
    // receycle bin (skip oracle 10g recycle bin system tables if enabled)
    config.setProperty(DatabaseConfig.FEATURE_SKIP_ORACLE_RECYCLEBIN_TABLES, Boolean.TRUE);

    return dbconn;
  }
View Full Code Here

TOP

Related Classes of org.dbunit.database.DatabaseConfig

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.