Search in sources :

Example 26 with DruidPooledStatement

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

the class PoolableStatementTest2 method test_MaxRows.

public void test_MaxRows() throws Exception {
    Connection conn = dataSource.getConnection();
    Statement stmt = conn.createStatement();
    stmt.setMaxRows(44);
    Assert.assertEquals(44, stmt.getMaxRows());
    ((DruidPooledStatement) stmt).getStatement().close();
    {
        SQLException error = null;
        try {
            stmt.getMaxRows();
        } catch (SQLException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        SQLException error = null;
        try {
            stmt.setMaxRows(23);
        } 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 27 with DruidPooledStatement

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

the class PoolableStatementTest2 method test_executeUpdate_6.

public void test_executeUpdate_6() throws Exception {
    Connection conn = dataSource.getConnection();
    Statement stmt = conn.createStatement();
    stmt.executeUpdate("SET 1", new String[0]);
    ((DruidPooledStatement) stmt).getStatement().close();
    {
        SQLException error = null;
        try {
            stmt.executeUpdate("SET 1", new String[0]);
        } 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 28 with DruidPooledStatement

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

the class PoolableStatementTest2 method test_executeUpdate_7.

public void test_executeUpdate_7() throws Exception {
    Connection conn = dataSource.getConnection();
    Statement stmt = conn.createStatement();
    stmt.executeUpdate("SET 1", new int[0]);
    ((DruidPooledStatement) stmt).getStatement().close();
    {
        SQLException error = null;
        try {
            stmt.executeUpdate("SET 1", new int[0]);
        } 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 29 with DruidPooledStatement

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

the class PoolableStatementTest2 method test_getResultSetConcurrency.

public void test_getResultSetConcurrency() throws Exception {
    Connection conn = dataSource.getConnection();
    Statement stmt = conn.createStatement();
    stmt.getResultSetConcurrency();
    ((DruidPooledStatement) stmt).getStatement().close();
    {
        SQLException error = null;
        try {
            stmt.getResultSetConcurrency();
        } 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 30 with DruidPooledStatement

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

the class PoolableStatementTest2 method test_cancel.

public void test_cancel() throws Exception {
    Connection conn = dataSource.getConnection();
    Statement stmt = conn.createStatement();
    stmt.cancel();
    ((DruidPooledStatement) stmt).getStatement().close();
    {
        SQLException error = null;
        try {
            stmt.cancel();
        } 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