Search in sources :

Example 71 with DruidDataSource

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);
}
Also used : DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Example 72 with DruidDataSource

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();
}
Also used : LocalSessionFactoryBean(org.springframework.orm.hibernate4.LocalSessionFactoryBean) IOException(java.io.IOException) Properties(java.util.Properties) DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Example 73 with DruidDataSource

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);
}
Also used : DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Example 74 with DruidDataSource

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();
}
Also used : Connection(java.sql.Connection) DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Example 75 with DruidDataSource

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);
}
Also used : DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Aggregations

DruidDataSource (com.alibaba.druid.pool.DruidDataSource)389 SQLException (java.sql.SQLException)56 OracleMockDriver (com.alibaba.druid.test.util.OracleMockDriver)55 OracleExceptionSorter (com.alibaba.druid.pool.vendor.OracleExceptionSorter)50 MockDriver (com.alibaba.druid.mock.MockDriver)48 Connection (java.sql.Connection)36 FilterAdapter (com.alibaba.druid.filter.FilterAdapter)35 Properties (java.util.Properties)34 FilterChain (com.alibaba.druid.filter.FilterChain)33 ResultSet (java.sql.ResultSet)19 ConnectionProxy (com.alibaba.druid.proxy.jdbc.ConnectionProxy)18 MockConnection (com.alibaba.druid.mock.MockConnection)13 ResultSetProxy (com.alibaba.druid.proxy.jdbc.ResultSetProxy)13 Method (java.lang.reflect.Method)11 PreparedStatement (java.sql.PreparedStatement)11 MockPreparedStatement (com.alibaba.druid.mock.MockPreparedStatement)10 Field (java.lang.reflect.Field)8 MockResultSet (com.alibaba.druid.mock.MockResultSet)7 TabularData (javax.management.openmbean.TabularData)7 MockCallableStatement (com.alibaba.druid.mock.MockCallableStatement)6