Search in sources :

Example 1 with DataSourceClosedException

use of com.alibaba.druid.pool.DataSourceClosedException in project druid by alibaba.

the class ClosedTest method test_close.

public void test_close() throws Exception {
    DruidDataSource dataSource = new DruidDataSource();
    dataSource.setUrl("jdbc:mock:xxx");
    Connection conn = dataSource.getConnection();
    conn.close();
    dataSource.close();
    DataSourceClosedException error = null;
    try {
        dataSource.getConnection();
    } catch (DataSourceClosedException ex) {
        error = ex;
    }
    Assert.assertNotNull(error);
}
Also used : DataSourceClosedException(com.alibaba.druid.pool.DataSourceClosedException) Connection(java.sql.Connection) DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Aggregations

DataSourceClosedException (com.alibaba.druid.pool.DataSourceClosedException)1 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)1 Connection (java.sql.Connection)1