Search in sources :

Example 11 with DruidPooledConnection

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

the class DataSourceTest3 method test_error_10.

public void test_error_10() throws Exception {
    DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);
    conn.close();
    {
        Exception error = null;
        try {
            dataSource.addConnectionProperty("x", "11");
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
}
Also used : DruidPooledConnection(com.alibaba.druid.pool.DruidPooledConnection) SQLException(java.sql.SQLException)

Example 12 with DruidPooledConnection

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

the class DataSourceTest3 method test_error_12.

public void test_error_12() throws Exception {
    DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);
    conn.close();
    {
        Exception error = null;
        try {
            dataSource.setDriverClassName("");
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
}
Also used : DruidPooledConnection(com.alibaba.druid.pool.DruidPooledConnection) SQLException(java.sql.SQLException)

Example 13 with DruidPooledConnection

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

the class DataSourceTest3 method test_error_validateConnection_3.

public void test_error_validateConnection_3() throws Exception {
    dataSource.setValidationQuery(null);
    dataSource.setValidConnectionChecker(new MySqlValidConnectionChecker());
    DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);
    dataSource.validateConnection(conn);
}
Also used : MySqlValidConnectionChecker(com.alibaba.druid.pool.vendor.MySqlValidConnectionChecker) DruidPooledConnection(com.alibaba.druid.pool.DruidPooledConnection)

Example 14 with DruidPooledConnection

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

the class DataSourceTest3 method test_error_7.

public void test_error_7() throws Exception {
    DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);
    conn.close();
    dataSource.setPassword(dataSource.getPassword());
    dataSource.setPassword("xx");
}
Also used : DruidPooledConnection(com.alibaba.druid.pool.DruidPooledConnection)

Example 15 with DruidPooledConnection

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

the class DataSourceTest3 method test_prepareStatement_error.

public void test_prepareStatement_error() throws Exception {
    DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);
    conn.close();
    {
        Exception error = null;
        try {
            dataSource.setUsername("xxx");
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
}
Also used : DruidPooledConnection(com.alibaba.druid.pool.DruidPooledConnection) SQLException(java.sql.SQLException)

Aggregations

DruidPooledConnection (com.alibaba.druid.pool.DruidPooledConnection)152 SQLException (java.sql.SQLException)99 PreparedStatement (java.sql.PreparedStatement)61 MockConnection (com.alibaba.druid.mock.MockConnection)49 Statement (java.sql.Statement)46 Connection (java.sql.Connection)20 MockPreparedStatement (com.alibaba.druid.mock.MockPreparedStatement)10 ConnectionProxy (com.alibaba.druid.proxy.jdbc.ConnectionProxy)7 DruidConnectionHolder (com.alibaba.druid.pool.DruidConnectionHolder)5 ResultSet (java.sql.ResultSet)5 DruidPooledPreparedStatement (com.alibaba.druid.pool.DruidPooledPreparedStatement)4 PreparedStatementHolder (com.alibaba.druid.pool.PreparedStatementHolder)4 Properties (java.util.Properties)4 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)3 EncodingConvertFilter (com.alibaba.druid.filter.encoding.EncodingConvertFilter)2 MockCallableStatement (com.alibaba.druid.mock.MockCallableStatement)2 MockResultSet (com.alibaba.druid.mock.MockResultSet)2 PreparedStatementKey (com.alibaba.druid.pool.DruidPooledPreparedStatement.PreparedStatementKey)2 PreparedStatementPool (com.alibaba.druid.pool.PreparedStatementPool)2 CountDownLatch (java.util.concurrent.CountDownLatch)2