当前位置: 首页>>代码示例>>Java>>正文


Java IDatabaseConnection.getConfig方法代码示例

本文整理汇总了Java中org.dbunit.database.IDatabaseConnection.getConfig方法的典型用法代码示例。如果您正苦于以下问题:Java IDatabaseConnection.getConfig方法的具体用法?Java IDatabaseConnection.getConfig怎么用?Java IDatabaseConnection.getConfig使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.dbunit.database.IDatabaseConnection的用法示例。


在下文中一共展示了IDatabaseConnection.getConfig方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.dbunit.database.IDatabaseConnection; //导入方法依赖的package包/类
/**
 * @param args
 *            args
 * @throws Exception
 *             Exception
 */
public static void main(String[] args) throws Exception {

    String prop = "src/test/resources/jdbc.properties";
    if (args.length > 0) {
        prop = args[0];
    }
    Properties p = loadProperties(prop);

    String input = "import.xls";
    if (args.length > 1) {
        input = args[1];
    }

    IDatabaseConnection con = createConnection(p);
    DatabaseConfig config = con.getConfig();
        config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY,
                           factorySelector.getDataTypeFactory(con));
    TableDataOperator op = new TableDataOperator();
    // op.deleteInsert(con, input);
    op.insertUpdate(con, input);
}
 
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:28,代码来源:DataImporter.java

示例2: getConnection

import org.dbunit.database.IDatabaseConnection; //导入方法依赖的package包/类
protected IDatabaseConnection getConnection() throws Exception
    {
        Configuration cfg = getHibernateConfiguration();
        String username = cfg.getProperty( "hibernate.connection.username" );
        String password = cfg.getProperty( "hibernate.connection.password" );
        String driver = cfg.getProperty( "hibernate.connection.driver_class" );
        String url = cfg.getProperty( "hibernate.connection.url" );

        Class.forName( driver );

        Connection jdbcConnection = DriverManager.getConnection( url, username, password );
        
        IDatabaseConnection connection =  new DatabaseConnection(jdbcConnection);
        DatabaseConfig config = connection.getConfig();
//        config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new H2DataTypeFactory());
        config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new HsqldbDataTypeFactory());
      
        return connection;
    }
 
开发者ID:strator-dev,项目名称:greenpepper,代码行数:20,代码来源:AbstractDBUnitHibernateMemoryTest.java

示例3: getConnection

import org.dbunit.database.IDatabaseConnection; //导入方法依赖的package包/类
protected IDatabaseConnection getConnection() throws Exception {
    Properties cfg = getHibernateConfiguration();
    String username = cfg.getProperty("hibernate.connection.username");
    String password = cfg.getProperty("hibernate.connection.password");
    String driver = cfg.getProperty("hibernate.connection.driver_class");
    String url = cfg.getProperty("hibernate.connection.url");

    Class.forName(driver);

    Connection jdbcConnection = DriverManager.getConnection(url, username, password);

    IDatabaseConnection connection = new DatabaseConnection(jdbcConnection);
    DatabaseConfig config = connection.getConfig();
    // config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new
    // H2DataTypeFactory());
    config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new HsqldbDataTypeFactory());

    return connection;
}
 
开发者ID:testIT-LivingDoc,项目名称:livingdoc-confluence,代码行数:20,代码来源:AbstractDBUnitHibernateMemoryTest.java

示例4: compareTables

import org.dbunit.database.IDatabaseConnection; //导入方法依赖的package包/类
public void compareTables(String expectedDatasetFileName, String... tableNames) throws Exception {
	JdbcDatabaseTester jdbc = new JdbcDatabaseTester("org.hsqldb.jdbcDriver", "jdbc:hsqldb:file:./db/example-db;ifexists=true;shutdown=true;", "sa", "");
	IDatabaseConnection connection = jdbc.getConnection();
	
	DatabaseConfig config = connection.getConfig();
	config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new HsqldbDataTypeFactory());
	
	IDataSet databaseDataSet = connection.createDataSet();
	IDataSet expectedDataSet = new FlatXmlDataFileLoader().load(expectedDatasetFileName);
	
	for (String tableName : tableNames) {
		ITable actualTable = databaseDataSet.getTable(tableName);
		ITable expectedTable = expectedDataSet.getTable(tableName);
		Assertion.assertEquals(expectedTable, actualTable);
	}
}
 
开发者ID:EsfingeFramework,项目名称:querybuilder,代码行数:17,代码来源:DataBaseCommunicator.java

示例5: create

import org.dbunit.database.IDatabaseConnection; //导入方法依赖的package包/类
@Override
public IDatabaseConnection create() {
	
	Connection jdbcConnection = this.getConnection();
	
	JdbcMetaDataExtractor extractor = new JdbcMetaDataExtractor(jdbcConnection);
	String userName = extractor.getUserName();
	
	try {
		IDatabaseConnection dbUnitConn = new OracleConnection(jdbcConnection, userName);
		DatabaseConfig config = dbUnitConn.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 dbUnitConn;
	} catch (DatabaseUnitException e) {
		throw new IllegalStateException(
				"It's not possible to create a Oracle DbUnit connection: "
						+ e.getMessage(), e);
	}
}
 
开发者ID:rponte,项目名称:dbunitmanager,代码行数:24,代码来源:OracleDbUnitConnectionCreator.java

示例6: connectionRetrieved

import org.dbunit.database.IDatabaseConnection; //导入方法依赖的package包/类
@Override
public void connectionRetrieved(final IDatabaseConnection connection) {
    final DatabaseConfig config = connection.getConfig();
    config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new PostgresqlDataTypeFactory());
    config.setProperty(DatabaseConfig.FEATURE_QUALIFIED_TABLE_NAMES, true);
    config.setProperty(DatabaseConfig.PROPERTY_BATCH_SIZE, 300);
    config.setProperty(DatabaseConfig.FEATURE_BATCHED_STATEMENTS, true);
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:9,代码来源:DBUnitLoaderTestExecutionListener.java

示例7: createConnection

import org.dbunit.database.IDatabaseConnection; //导入方法依赖的package包/类
/**
 * Geeft een door DBUnit gewrapte connectie terug naar de testdatabase.
 * @return Een DBUnit {@link IDatabaseConnection} naar de testdatabase.
 * @throws SQLException on error
 * @throws DatabaseUnitException on error
 */
public IDatabaseConnection createConnection() throws DatabaseUnitException, SQLException {
    final IDatabaseConnection connection = new DatabaseConnection(createSqlConnection());
    final DatabaseConfig config = connection.getConfig();
    config.setProperty(DatabaseConfig.FEATURE_QUALIFIED_TABLE_NAMES, Boolean.TRUE);
    config.setProperty(DatabaseConfig.FEATURE_BATCHED_STATEMENTS, Boolean.TRUE);
    config.setProperty(DatabaseConfig.PROPERTY_BATCH_SIZE, INT_5000);
    if (inMemory) {
        config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new HsqldbDataTypeFactory());
    } else {
        config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new PostgresqlDataTypeFactory());
    }
    return connection;
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:20,代码来源:AbstractDBUnitUtil.java

示例8: getSetUpOperation

import org.dbunit.database.IDatabaseConnection; //导入方法依赖的package包/类
protected DatabaseOperation getSetUpOperation() throws Exception {
	parseCreateTableScriptFile();

	initSpringContext();

	return new CompositeOperation(new DatabaseOperation[] { new DatabaseOperation() {

		@Override
		public void execute(IDatabaseConnection connection, IDataSet dataSet)
				throws DatabaseUnitException, SQLException {

			DatabaseConfig databaseConfig = connection.getConfig();
			IStatementFactory statementFactory = (IStatementFactory) databaseConfig
					.getProperty(DatabaseConfig.PROPERTY_STATEMENT_FACTORY);
			IBatchStatement statement = statementFactory.createBatchStatement(connection);
			try {
				int count = 0;
				for (SingleCreateTableScriptEntry entry : createdTableList) {
					statement.addBatch(entry.getCreateTableScript());
					count++;
				}

				if (count > 0) {
					statement.executeBatch();
					statement.clearBatch();
				}
			} finally {
				statement.close();
			}
		}
	}, DatabaseOperation.CLEAN_INSERT });
}
 
开发者ID:dianping,项目名称:zebra,代码行数:33,代码来源:SingleDBBaseTestCase.java

示例9: getTearDownOperation

import org.dbunit.database.IDatabaseConnection; //导入方法依赖的package包/类
protected DatabaseOperation getTearDownOperation() throws Exception {
	return new DatabaseOperation() {

		@Override
		public void execute(IDatabaseConnection connection, IDataSet dataSet)
				throws DatabaseUnitException, SQLException {

			DatabaseConfig databaseConfig = connection.getConfig();
			IStatementFactory statementFactory = (IStatementFactory) databaseConfig
					.getProperty(DatabaseConfig.PROPERTY_STATEMENT_FACTORY);
			IBatchStatement statement = statementFactory.createBatchStatement(connection);

			try {
				int count = 0;
				for (SingleCreateTableScriptEntry entry : createdTableList) {
					statement.addBatch("drop table " + entry.getTableName());
					count++;
				}

				if (count > 0) {
					statement.executeBatch();
					statement.clearBatch();
				}
			} finally {
				statement.close();
			}

		}
	};
}
 
开发者ID:dianping,项目名称:zebra,代码行数:31,代码来源:SingleDBBaseTestCase.java

示例10: execute

import org.dbunit.database.IDatabaseConnection; //导入方法依赖的package包/类
@Override
public void execute(IDatabaseConnection connection, IDataSet dataSet) throws DatabaseUnitException, SQLException {
    DatabaseConfig databaseConfig = connection.getConfig();
    IStatementFactory statementFactory = (IStatementFactory) databaseConfig.getProperty(DatabaseConfig.PROPERTY_STATEMENT_FACTORY);

    IBatchStatement statement = statementFactory.createBatchStatement(connection);
    try {
        int count = 0;

        ITableIterator iterator = dataSet.iterator();
        while (iterator.next()) {
            String tableName = iterator.getTableMetaData().getTableName();

            StringBuilder sql = new StringBuilder();
            sql.append("delete from ");
            sql.append(this.getQualifiedName(this.schema, tableName, connection));
            statement.addBatch(sql.toString());

            count++;
        }

        if (count > 0) {
            statement.executeBatch();
            statement.clearBatch();
        }
    } finally {
        statement.close();
    }
}
 
开发者ID:0xC70FF3,项目名称:java-gems,代码行数:30,代码来源:SchemaSpecificDeleteAllOperation.java

示例11: getConnection

import org.dbunit.database.IDatabaseConnection; //导入方法依赖的package包/类
public IDatabaseConnection getConnection() throws Exception {
    IDatabaseConnection connection = super.getConnection();
    DatabaseConfig config = connection.getConfig();
    config.setProperty(DatabaseConfig.FEATURE_CASE_SENSITIVE_TABLE_NAMES, true);
    config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new MySqlDataTypeFactory());
    return connection;
}
 
开发者ID:MyCollab,项目名称:mycollab,代码行数:8,代码来源:DbUnitInitializerRule.java

示例12: compareTables

import org.dbunit.database.IDatabaseConnection; //导入方法依赖的package包/类
protected void compareTables(String expectedDatasetFileName, String... tableNames) throws Exception {
	IDatabaseConnection connection = jdt.getConnection();
	
	DatabaseConfig config = connection.getConfig();
	config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new HsqldbDataTypeFactory());
	
	IDataSet databaseDataSet = connection.createDataSet();
	IDataSet expectedDataSet = new FlatXmlDataFileLoader().load(expectedDatasetFileName);
	for (String tableName : tableNames) {
		ITable actualTable = databaseDataSet.getTable(tableName);
		ITable expectedTable = expectedDataSet.getTable(tableName);
		Assertion.assertEquals(expectedTable, actualTable);
	}
}
 
开发者ID:EsfingeFramework,项目名称:querybuilder,代码行数:15,代码来源:QueryBuilderDatabaseTest.java

示例13: createConnection

import org.dbunit.database.IDatabaseConnection; //导入方法依赖的package包/类
IDatabaseConnection createConnection()
    throws Exception
{

    // Instantiate JDBC driver
    Class dc = Class.forName( driver );
    Driver driverInstance = (Driver) dc.newInstance();
    Properties info = new Properties();
    info.put( "user", username );

    if ( password != null )
    {
        info.put( "password", password );
    }

    Connection conn = driverInstance.connect( url, info );

    if ( conn == null )
    {
        // Driver doesn't understand the URL
        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.setFeature( DatabaseConfig.FEATURE_SKIP_ORACLE_RECYCLEBIN_TABLES, this.skipOracleRecycleBinTables );
    config.setFeature( DatabaseConfig.FEATURE_CASE_SENSITIVE_TABLE_NAMES, caseSensitiveTableNames );
    
    config.setProperty( DatabaseConfig.PROPERTY_ESCAPE_PATTERN, escapePattern );
    config.setProperty( DatabaseConfig.PROPERTY_RESULTSET_TABLE_FACTORY, new ForwardOnlyResultSetTableFactory() );

    // Setup data type factory
    IDataTypeFactory dataTypeFactory = (IDataTypeFactory) Class.forName( dataTypeFactoryName ).newInstance();
    config.setProperty( DatabaseConfig.PROPERTY_DATATYPE_FACTORY, dataTypeFactory );

    // Setup metadata handler
    IMetadataHandler metadataHandler = (IMetadataHandler) Class.forName( metadataHandlerName ).newInstance();
    config.setProperty( DatabaseConfig.PROPERTY_METADATA_HANDLER, metadataHandler );

    return connection;
}
 
开发者ID:mojohaus,项目名称:dbunit-maven-plugin,代码行数:46,代码来源:AbstractDbUnitMojo.java

示例14: createConnection

import org.dbunit.database.IDatabaseConnection; //导入方法依赖的package包/类
IDatabaseConnection createConnection()
	throws Exception {

	// Instantiate JDBC driver
	Class dc = Class.forName(driver);
	Driver driverInstance = (Driver) dc.newInstance();
	Properties info = new Properties();
	info.put("user", username);

	if (password != null) {
		info.put("password", password);
	}

	Connection conn = driverInstance.connect(url, info);

	if (conn == null) {
		// Driver doesn't understand the URL
		throw new SQLException("No suitable Driver for " + url);
	}
	conn.setAutoCommit(true);

	IDatabaseConnection connection = new DatabaseConnection(conn, schema);
	DatabaseConfig config = connection.getConfig();
	config.setProperty(DatabaseConfig.FEATURE_BATCHED_STATEMENTS, supportBatchStatement);
	config.setProperty(DatabaseConfig.FEATURE_QUALIFIED_TABLE_NAMES, useQualifiedTableNames);
	config.setProperty(DatabaseConfig.FEATURE_DATATYPE_WARNING, datatypeWarning);
	config.setProperty(DatabaseConfig.FEATURE_SKIP_ORACLE_RECYCLEBIN_TABLES, this.skipOracleRecycleBinTables);
	config.setProperty(DatabaseConfig.FEATURE_CASE_SENSITIVE_TABLE_NAMES, caseSensitiveTableNames);

	config.setProperty(DatabaseConfig.PROPERTY_ESCAPE_PATTERN, escapePattern);
	config.setProperty(DatabaseConfig.PROPERTY_RESULTSET_TABLE_FACTORY, new ForwardOnlyResultSetTableFactory());

	// Setup data type factory
	IDataTypeFactory dataTypeFactory = (IDataTypeFactory) Class.forName(dataTypeFactoryName).newInstance();
	config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, dataTypeFactory);

	// Setup metadata handler
	IMetadataHandler metadataHandler = (IMetadataHandler) Class.forName(metadataHandlerName).newInstance();
	config.setProperty(DatabaseConfig.PROPERTY_METADATA_HANDLER, metadataHandler);

	return connection;
}
 
开发者ID:lotaris,项目名称:lotaris-dbunit-maven-plugin,代码行数:43,代码来源:AbstractDbUnitMojo.java


注:本文中的org.dbunit.database.IDatabaseConnection.getConfig方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。