use of com.alibaba.druid.pool.DruidDataSource in project druid by alibaba.
the class DruidConnectionHolderTest method setUp.
protected void setUp() throws Exception {
super.setUp();
driver = new Driver();
if (driver.getMajorVersion() == 5) {
exceptionClass = Class.forName("com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException");
dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:mock:xxx");
dataSource.setTestOnBorrow(false);
dataSource.setInitialSize(1);
dataSource.getProxyFilters().add(new FilterAdapter() {
public int connection_getTransactionIsolation(FilterChain chain, ConnectionProxy connection) throws SQLException {
throw createSyntaxException();
}
});
}
}
use of com.alibaba.druid.pool.DruidDataSource in project druid by alibaba.
the class DruidConnectionHolderTest3 method setUp.
protected void setUp() throws Exception {
super.setUp();
dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:mock:xxx");
dataSource.setTestOnBorrow(false);
dataSource.setInitialSize(1);
dataSource.getProxyFilters().add(new FilterAdapter() {
public int connection_getTransactionIsolation(FilterChain chain, ConnectionProxy connection) throws SQLException {
throw new MySQLException();
}
});
}
use of com.alibaba.druid.pool.DruidDataSource in project druid by alibaba.
the class DruidDataSourceDecryptTest method testDecrypt.
@Test
public void testDecrypt() throws SQLException {
DruidDataSource dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:oracle:thin:@");
dataSource.setUsername("xiaoyu");
dataSource.setPassword("OJfUm6WCHi7EuXqE6aEc+Po2xFrAGBeSNy8O2jWhV2FTG8/5kbRRr2rjNKhptlevm/03Y0048P7h88gdUOXAYg==");
dataSource.setFilters("config");
dataSource.setConnectionProperties("config.decrypt=true");
try {
dataSource.init();
Assert.assertEquals("The password is " + dataSource.getPassword(), "xiaoyu", dataSource.getPassword());
} finally {
JdbcUtils.close(dataSource);
}
}
use of com.alibaba.druid.pool.DruidDataSource in project druid by alibaba.
the class Bug_for_dupCloseStmtError method tearDown.
protected void tearDown() throws Exception {
dataSource.close();
for (DruidDataSource dataSource : DruidDataSourceStatManager.getDruidDataSourceInstances()) {
JdbcUtils.close(dataSource);
}
super.tearDown();
}
use of com.alibaba.druid.pool.DruidDataSource in project druid by alibaba.
the class Bug_for_dupCloseStmtError method setUp.
protected void setUp() throws Exception {
super.setUp();
dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:mock:");
dataSource.setPoolPreparedStatements(false);
dataSource.setTestOnBorrow(true);
}
Aggregations