Search in sources :

Example 6 with DruidPooledStatement

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

the class ResultSetTest method setUp.

protected void setUp() throws Exception {
    stmt = new DruidPooledStatement(null, null) {

        protected SQLException checkException(Throwable error) throws SQLException {
            if (error instanceof SQLException) {
                return (SQLException) error;
            }
            return new SQLException(error);
        }
    };
    raw = new MockResultSet(null);
    raw.getRows().add(new Object[] { null });
    resultSet = new DruidPooledResultSet(stmt, raw);
}
Also used : DruidPooledStatement(com.alibaba.druid.pool.DruidPooledStatement) SQLException(java.sql.SQLException) MockResultSet(com.alibaba.druid.mock.MockResultSet) DruidPooledResultSet(com.alibaba.druid.pool.DruidPooledResultSet)

Example 7 with DruidPooledStatement

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

the class PoolableStatementTest2 method test_getMoreResults_1.

public void test_getMoreResults_1() throws Exception {
    Connection conn = dataSource.getConnection();
    Statement stmt = conn.createStatement();
    stmt.getMoreResults(1);
    ((DruidPooledStatement) stmt).getStatement().close();
    {
        SQLException error = null;
        try {
            stmt.getMoreResults(1);
        } catch (SQLException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    stmt.close();
    conn.close();
}
Also used : SQLException(java.sql.SQLException) DruidPooledStatement(com.alibaba.druid.pool.DruidPooledStatement) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) CallableStatement(java.sql.CallableStatement) Connection(java.sql.Connection)

Example 8 with DruidPooledStatement

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

the class PoolableStatementTest2 method test_getUpdateCount.

public void test_getUpdateCount() throws Exception {
    Connection conn = dataSource.getConnection();
    Statement stmt = conn.createStatement();
    stmt.getUpdateCount();
    stmt.executeQuery("select 1");
    ((DruidPooledStatement) stmt).getStatement().close();
    {
        SQLException error = null;
        try {
            stmt.getUpdateCount();
        } catch (SQLException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    stmt.close();
    conn.close();
}
Also used : SQLException(java.sql.SQLException) DruidPooledStatement(com.alibaba.druid.pool.DruidPooledStatement) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) CallableStatement(java.sql.CallableStatement) Connection(java.sql.Connection)

Example 9 with DruidPooledStatement

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

the class PoolableStatementTest2 method test_getMoreResults.

public void test_getMoreResults() throws Exception {
    Connection conn = dataSource.getConnection();
    Statement stmt = conn.createStatement();
    stmt.getMoreResults();
    ((DruidPooledStatement) stmt).getStatement().close();
    {
        SQLException error = null;
        try {
            stmt.getMoreResults();
        } catch (SQLException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    stmt.close();
    conn.close();
}
Also used : SQLException(java.sql.SQLException) DruidPooledStatement(com.alibaba.druid.pool.DruidPooledStatement) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) CallableStatement(java.sql.CallableStatement) Connection(java.sql.Connection)

Example 10 with DruidPooledStatement

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

the class PoolableStatementTest2 method test_clearWarnings.

public void test_clearWarnings() throws Exception {
    Connection conn = dataSource.getConnection();
    Statement stmt = conn.createStatement();
    stmt.clearWarnings();
    ((DruidPooledStatement) stmt).getStatement().close();
    {
        SQLException error = null;
        try {
            stmt.clearWarnings();
        } catch (SQLException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    stmt.close();
    conn.close();
}
Also used : SQLException(java.sql.SQLException) DruidPooledStatement(com.alibaba.druid.pool.DruidPooledStatement) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) CallableStatement(java.sql.CallableStatement) Connection(java.sql.Connection)

Aggregations

DruidPooledStatement (com.alibaba.druid.pool.DruidPooledStatement)39 SQLException (java.sql.SQLException)39 Connection (java.sql.Connection)35 CallableStatement (java.sql.CallableStatement)33 PreparedStatement (java.sql.PreparedStatement)33 Statement (java.sql.Statement)33 MockResultSet (com.alibaba.druid.mock.MockResultSet)3 DruidPooledResultSet (com.alibaba.druid.pool.DruidPooledResultSet)2 SQLFeatureNotSupportedException (java.sql.SQLFeatureNotSupportedException)2 MockStatement (com.alibaba.druid.mock.MockStatement)1