1. IDatabaseTester 또는 IDatabaseConnection 사용 시 경고 메시지
2. MySqlConnection 사용 예제
MySqlConnection, OracleConnection, Db2Connection 등 해당 DBMS의 Connection 사용
WARN : org.dbunit.dataset.AbstractTableMetaData - Potential problem found: The configured data type factory 'class org.dbunit.dataset.datatype.DefaultDataTypeFactory' might cause problems with the current database 'MySQL' (e.g. some datatypes may not be supported properly). In rare cases you might see this message because the list of supported database products is incomplete (list=[derby]). If so please request a java-class update via the forums.If you are using your own IDataTypeFactory extending DefaultDataTypeFactory, ensure that you override getValidDbProducts() to specify the supported database products.
2. MySqlConnection 사용 예제
MySqlConnection, OracleConnection, Db2Connection 등 해당 DBMS의 Connection 사용
private final static String driverClass = "com.mysql.jdbc.Driver";private final static String connectionUrl = "jdbc:mysql://localhost/testdb";private final static String username = "testdb";private final static String password = "testdb";private final static String schema = "testdb";//private IDatabaseTester databaseTester;
public static Connection getConnection() throws InstantiationException, IllegalAccessException, ClassNotFoundException {Connection conn = null;try {Class.forName(driverClass);conn = DriverManager.getConnection(connectionUrl, username, password);} catch (SQLException e) {// TODO Auto-generated catch blocke.printStackTrace();}return conn;}
@Beforepublic void setUp() throws Exception {//databaseTester = new JdbcDatabaseTester(driverClass, connectionUrl, username, password);//IDatabaseConnection connection = new DatabaseConnection(getConnection());IDatabaseConnection connection = new MySqlConnection(getConnection(), schema);try {IDataSet dataSet = new FlatXmlDataSetBuilder().build(new File("resetDB.xml"));//DatabaseOperation.CLEAN_INSERT.execute(databaseTester.getConnection(), dataSet);DatabaseOperation.CLEAN_INSERT.execute(connection, dataSet);} catch (Exception e) {// TODO: handle exception//databaseTester.getConnection().close();connection.close();}}
'Develop > SERVER SIDE' 카테고리의 다른 글
하둡 클러스터 환경 및 R 분석 서버 구축 (0) | 2015.12.08 |
---|---|
Spring JAXB를 활용한 Tree 구현 (0) | 2012.06.09 |
Spring quartz(Scheduler) 사용 (0) | 2011.12.09 |
Spring Bean을 Servlet Filter에서 사용 (1) | 2011.12.09 |
MSSQL 트랜잭션 로그 파일 초기화 (0) | 2011.12.08 |
Recent Comment