use of com.alibaba.druid.pool.DruidDataSource in project druid by alibaba.
the class WallFilterTest method setUp.
protected void setUp() throws Exception {
dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:h2:mem:wall_test;");
dataSource.setFilters("wall");
dataSource.init();
wallFilter = (WallFilter) dataSource.getProxyFilters().get(0);
}
use of com.alibaba.druid.pool.DruidDataSource in project druid by alibaba.
the class HibernateCRUDTest method setUp.
@Override
public void setUp() throws Exception {
/*init dataSource*/
dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:h2:file:~/.h2/HibernateCRUDTest;AUTO_SERVER=TRUE");
dataSource.setUsername("sa");
dataSource.setPassword("");
dataSource.setDefaultAutoCommit(false);
dataSource.setFilters("log4j");
/*init sessionFactory*/
LocalSessionFactoryBean factoryBean = new LocalSessionFactoryBean();
factoryBean.setDataSource(dataSource);
Properties prop = new Properties();
prop.put("hibernate.show_sql", "true");
//prop.put("hibernate.format_sql", "true");
prop.put("hibernate.hbm2ddl.auto", "create");
prop.put("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
factoryBean.setHibernateProperties(prop);
factoryBean.setAnnotatedClasses(new Class<?>[] { Sample.class });
try {
factoryBean.afterPropertiesSet();
} catch (IOException e) {
e.printStackTrace();
}
sessionFactory = factoryBean.getObject();
}
use of com.alibaba.druid.pool.DruidDataSource in project druid by alibaba.
the class DupRegisterTest method setUp.
protected void setUp() throws Exception {
dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:mock:xxx");
dataSource.setMinEvictableIdleTimeMillis(10);
dataSource.setTimeBetweenEvictionRunsMillis(10);
}
use of com.alibaba.druid.pool.DruidDataSource in project druid by alibaba.
the class LoggerTest method test_log.
public void test_log() throws Exception {
TestLoader classLoader = new TestLoader();
Thread.currentThread().setContextClassLoader(classLoader);
dataSource = new DruidDataSource();
dataSource.setFilters("log");
dataSource.setUrl("jdbc:mock:xx");
Connection conn = dataSource.getConnection();
conn.close();
}
use of com.alibaba.druid.pool.DruidDataSource in project druid by alibaba.
the class Bug_for_dupCloseStmtError method setUp.
protected void setUp() throws Exception {
dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:mock:");
dataSource.setPoolPreparedStatements(false);
dataSource.setTestOnBorrow(true);
}
Aggregations