Package org.dbunit.database

Examples of org.dbunit.database.DatabaseConfig


  private BasicDataSource dataSource;
 
  @Override
  protected IDatabaseConnection getConnection() throws Exception {
    IDatabaseConnection dc = new DatabaseConnection(dataSource.getConnection());
    DatabaseConfig config = dc.getConfig();
    config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY,
        new MySqlDataTypeFactory());
    return dc;
  }
View Full Code Here


    dataSource.setPassword("gnizr");
    dataSource.setUrl("jdbc:mysql://localhost/gnizr_db");
    dataSource.setDriverClassName("com.mysql.jdbc.Driver");
   
    IDatabaseConnection dc = new DatabaseConnection(dataSource.getConnection());
    DatabaseConfig config = dc.getConfig();
    config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY,
        new MySqlDataTypeFactory());

        // full database export
        IDataSet fullDataSet = dc.createDataSet();
        FlatXmlDataSet.write(fullDataSet, new FileOutputStream("full.xml"));            
View Full Code Here

                if (System.getProperty("mysql.password") != null) {
                    password = System.getProperty("mysql.password");
                }
            }
            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());
            }

            FlatXmlDataSetBuilder builder = new FlatXmlDataSetBuilder();
            builder.setColumnSensing(true);
            IDataSet ds = builder.build(new File(file));
View Full Code Here

        }
        return storageNodes.get(0);
    }

    void setDbType(IDatabaseConnection connection) throws Exception {
        DatabaseConfig dbConfig = connection.getConfig();
        String name = connection.getConnection().getMetaData().getDatabaseProductName().toLowerCase();
        int major = connection.getConnection().getMetaData().getDatabaseMajorVersion();
        IDataTypeFactory type = null;

        if (name.contains("postgres")) {
            type = new PostgresqlDataTypeFactory();
        } else if (name.contains("oracle")) {
            if (major >= 10) {
                type = new Oracle10DataTypeFactory();
            } else {
                type = new OracleDataTypeFactory();
            }
        }

        if (type != null) {
            dbConfig.setProperty("http://www.dbunit.org/properties/datatypeFactory", type);
        }
    }
View Full Code Here

            }
        }
    }

    void setDbType(IDatabaseConnection connection) throws Exception {
        DatabaseConfig dbConfig = connection.getConfig();
        String name = connection.getConnection().getMetaData().getDatabaseProductName().toLowerCase();
        int major = connection.getConnection().getMetaData().getDatabaseMajorVersion();
        IDataTypeFactory type = null;

        if (name.contains("postgres")) {
            type = new PostgresqlDataTypeFactory();
        } else if (name.contains("oracle")) {
            if (major >= 10) {
                type = new Oracle10DataTypeFactory();
            } else {
                type = new OracleDataTypeFactory();
            }
        }

        if (type != null) {
            dbConfig.setProperty("http://www.dbunit.org/properties/datatypeFactory", type);
        }
    }
View Full Code Here

            }
        }
    }

    private void setDbType(IDatabaseConnection connection) throws Exception {
        DatabaseConfig config = connection.getConfig();
        String name = connection.getConnection().getMetaData().getDatabaseProductName().toLowerCase();
        int major = connection.getConnection().getMetaData().getDatabaseMajorVersion();
        IDataTypeFactory type = null;
        if (name.contains("postgres")) {
            type = new org.dbunit.ext.postgresql.PostgresqlDataTypeFactory();
        } else if (name.contains("oracle")) {
            if (major >= 10) {
                type = new org.dbunit.ext.oracle.Oracle10DataTypeFactory();
            } else {
                type = new org.dbunit.ext.oracle.OracleDataTypeFactory();
            }
        }
        if (type != null) {
            config.setProperty("http://www.dbunit.org/properties/datatypeFactory", type);
        }
    }
View Full Code Here

        System.out.flush();
        System.err.flush();
    }

    private void setDatabaseType(IDatabaseConnection connection) throws SQLException {
        DatabaseConfig config = connection.getConfig();
        String name = connection.getConnection().getMetaData().getDatabaseProductName().toLowerCase();
        int major = connection.getConnection().getMetaData().getDatabaseMajorVersion();
        IDataTypeFactory type = null;
        if (name.contains("postgres")) {
            type = new org.dbunit.ext.postgresql.PostgresqlDataTypeFactory();
        } else if (name.contains("oracle")) {
            if (major>=10) {
                type = new org.dbunit.ext.oracle.Oracle10DataTypeFactory();
            } else {
                type = new org.dbunit.ext.oracle.OracleDataTypeFactory();
            }
        }
        if (type!=null) {
            LOG.info("setting db type for dbunit to " + type.getClass().getCanonicalName());
            config.setProperty("http://www.dbunit.org/properties/datatypeFactory",type);
        }
    }
View Full Code Here

            assert null != conn;
            IDatabaseConnection dbunitConn = new DatabaseConnection(conn);
            // only if we are running against HSQL
            String dbProdName = conn.getMetaData().getDatabaseProductName();
            if (dbProdName.toLowerCase().contains("hsql")) {
                DatabaseConfig config = dbunitConn.getConfig();
                config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY,
                        new HsqlDataTypeFactory());
            }
            IDataSet dataSet = loadDataSet(dbunitConn);
            databaseTester = new DefaultDatabaseTester(dbunitConn);
            databaseTester.setDataSet(dataSet);
View Full Code Here

*/
class HsqldbConfig implements VendorConfig {

  @Override
  public void configure(IDatabaseConnection connection) {
    DatabaseConfig config = connection.getConfig();

    config.setProperty(DBUnit.DATATYPE_FACTORY, new HsqldbDataTypeFactory());

    config.setProperty(DBUnit.QUALIFIED_TABLE_NAMES, true);
  }
View Full Code Here

    this.catalogs = catalogs;
  }

  @Override
  public void configure(IDatabaseConnection connection) {
    DatabaseConfig config = connection.getConfig();

    config.setProperty(DBUnit.DATATYPE_FACTORY, new MySqlDataTypeFactory());

    config.setProperty(DBUnit.ESCAPE_PATTERN, "`?`");

    config.setProperty(DBUnit.METADATA_HANDLER, new MySqlMetadataHandler(catalogs));

    config.setProperty(DBUnit.QUALIFIED_TABLE_NAMES, true);
  }
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.