本文整理汇总了Java中org.dbunit.ext.mysql.MySqlDataTypeFactory类的典型用法代码示例。如果您正苦于以下问题:Java MySqlDataTypeFactory类的具体用法?Java MySqlDataTypeFactory怎么用?Java MySqlDataTypeFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MySqlDataTypeFactory类属于org.dbunit.ext.mysql包,在下文中一共展示了MySqlDataTypeFactory类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: insertDbUnitTestdata
import org.dbunit.ext.mysql.MySqlDataTypeFactory; //导入依赖的package包/类
/**
* Inserts test data in DbUnit XML format.
*
* @param entityManager
* the EntityManager
* @param dbUnitTestdata
* test file stream
*/
public static void insertDbUnitTestdata(EntityManager entityManager, final InputStream dbUnitTestdata) {
entityManager.unwrap(Session.class).doWork(new Work() {
@Override
public void execute(Connection connection) throws SQLException {
// Insert Testdata
try {
LOGGER.debug("INSERTing testdata");
DatabaseConnection databaseConnection = new DatabaseConnection(connection);
databaseConnection.getConfig().setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY,
new MySqlDataTypeFactory());
FlatXmlDataSet dataSet = new FlatXmlDataSet(
new FlatXmlProducer(new InputSource(dbUnitTestdata), false, true));
DatabaseOperation.CLEAN_INSERT.execute(databaseConnection, dataSet);
LOGGER.debug("INSERTing testdata ... done");
} catch (DatabaseUnitException e) {
throw new SQLException(e);
}
}
});
}
示例2: init
import org.dbunit.ext.mysql.MySqlDataTypeFactory; //导入依赖的package包/类
@PostConstruct
void init() throws SQLException, DatabaseUnitException {
new File(root).mkdirs();
conn = new DatabaseConnection(dataSource.getConnection());
DatabaseConfig config = conn.getConfig();
switch (driver) {
case "com.mysql.jdbc.Driver":
config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new MySqlDataTypeFactory());
break;
case "org.postgresql.Driver":
config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new PostgresqlDataTypeFactory());
break;
default:
log.info("Not support database: " + driver);
}
}
示例3: configDatabaseProperties
import org.dbunit.ext.mysql.MySqlDataTypeFactory; //导入依赖的package包/类
private void configDatabaseProperties() throws SQLException {
DatabaseConfig config = dbUnitConnection.getConfig();
for (Map.Entry<String, Object> p : dbUnitConfig.getProperties().entrySet()) {
ConfigProperty byShortName = DatabaseConfig.findByShortName(p.getKey());
if (byShortName != null) {
config.setProperty(byShortName.getProperty(), p.getValue());
}
}
switch (dbType) {
case HSQLDB:
config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new HsqldbDataTypeFactory());
break;
case H2:
config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new H2DataTypeFactory());
break;
case MYSQL:
config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new MySqlDataTypeFactory());
break;
case POSTGRESQL:
config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new PostgresqlDataTypeFactory());
break;
case ORACLE:
config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new Oracle10DataTypeFactory());
break;
}
}
示例4: getConnection
import org.dbunit.ext.mysql.MySqlDataTypeFactory; //导入依赖的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;
}
示例5: init
import org.dbunit.ext.mysql.MySqlDataTypeFactory; //导入依赖的package包/类
/**
* Method to insert data before test. throws Exception from DB.
*
* @throws Exception
* the exception
*/
public void init() throws Exception {
DatabaseLoader.logger.debug("DatabaseLoader.init()");
try {
DatabaseLoader.logger.debug("starting init() in DatabaseLoader...");
this.dbConn = new DatabaseConnection(DataSourceUtils.getConnection(dataSource), this.schema);
DatabaseConfig config = dbConn.getConfig();
config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new MySqlDataTypeFactory());
config.setProperty(DatabaseConfig.PROPERTY_METADATA_HANDLER, new MySqlMetadataHandler());
config.setProperty(DatabaseConfig.FEATURE_CASE_SENSITIVE_TABLE_NAMES, Boolean.TRUE);
DatabaseLoader.logger.debug("DATASOURCE." + dataSource.toString());
this.loader = new FlatXmlDataSetBuilder();
dbConn.getConnection().createStatement().execute("DELETE FROM dbe_transaction");
deleteAll("dbunit/CREATE_DATATEST_III.xml", false);
deleteAll("dbunit/CREATE_DATATEST_II.xml", false);
deleteAll("dbunit/CREATE_DATATEST_I.xml", false);
cleanInsert("dbunit/CREATE_DATATEST_I.xml", false);
cleanInsert("dbunit/CREATE_DATATEST_II.xml", false);
cleanInsert("dbunit/CREATE_DATATEST_III.xml", true);
DatabaseLoader.logger.debug("ending init() in DatabaseLoader...");
} catch (Exception e) {
DatabaseLoader.logger.error("Error loading data init in DatabaseLoader");
dbConn.getConnection().rollback();
e.printStackTrace();
throw e;
}
}
示例6: setupConnections
import org.dbunit.ext.mysql.MySqlDataTypeFactory; //导入依赖的package包/类
@Before
public void setupConnections() throws SQLException, DatabaseUnitException, ClassNotFoundException {
MysqlDataSource dataSource = new MysqlDataSource();
dataSource.setURL(System.getProperty("db.url"));
dataSource.setUser(System.getProperty("db.userid"));
dataSource.setPassword(System.getProperty("db.password"));
this.dataSource = dataSource;
DatabaseConnection databaseConnection = new DatabaseConnection(getDataSource().getConnection());
databaseConnection.getConfig().setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new MySqlDataTypeFactory());
this.databaseConnection = databaseConnection;
defaultSupport = new DbTestSelectSupport(getDataSource());
}
示例7: setupConnections
import org.dbunit.ext.mysql.MySqlDataTypeFactory; //导入依赖的package包/类
@Before
public void setupConnections() throws SQLException, DatabaseUnitException, ClassNotFoundException {
MysqlDataSource dataSource = new MysqlDataSource();
dataSource.setURL(JDBC_URL);
dataSource.setUser(DB_USER);
dataSource.setPassword(DB_PASSWORD);
this.dataSource = dataSource;
DatabaseConnection databaseConnection = new DatabaseConnection(getDataSource().getConnection());
databaseConnection.getConfig().setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new MySqlDataTypeFactory());
this.databaseConnection = databaseConnection;
defaultSelectSupport = new DbTestSelectSupport(getDataSource());
}
示例8: dbUnitDatabaseConfig
import org.dbunit.ext.mysql.MySqlDataTypeFactory; //导入依赖的package包/类
/**
* custom configuration since we have case-sensitive table names and requiring
* MySQL specifics
*/
@Bean
public DatabaseConfigBean dbUnitDatabaseConfig() {
DatabaseConfigBean config = new DatabaseConfigBean();
config.setDatatypeFactory(new MySqlDataTypeFactory());
config.setMetadataHandler(new MySqlMetadataHandler());
config.setCaseSensitiveTableNames(true);
config.setAllowEmptyFields(true);
return config;
}
示例9: setUpDatabaseConfig
import org.dbunit.ext.mysql.MySqlDataTypeFactory; //导入依赖的package包/类
@Override
protected void setUpDatabaseConfig(DatabaseConfig config) {
super.setUpDatabaseConfig(config);
config.setProperty("http://www.dbunit.org/properties/datatypeFactory", new MySqlDataTypeFactory());
}