diff --git a/src/test/java/com/alibaba/druid/bvt/pool/basic/PoolableStatementTest.java b/src/test/java/com/alibaba/druid/bvt/pool/basic/PoolableStatementTest.java index d4313f7fd2..9f6105c861 100644 --- a/src/test/java/com/alibaba/druid/bvt/pool/basic/PoolableStatementTest.java +++ b/src/test/java/com/alibaba/druid/bvt/pool/basic/PoolableStatementTest.java @@ -1,5 +1,6 @@ package com.alibaba.druid.bvt.pool.basic; +import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; @@ -40,7 +41,5 @@ public class PoolableStatementTest extends TestCase { stmt.toString(); } - public void test_MaxRows() throws Exception { - - } + } diff --git a/src/test/java/com/alibaba/druid/bvt/pool/basic/PoolableStatementTest2.java b/src/test/java/com/alibaba/druid/bvt/pool/basic/PoolableStatementTest2.java index 72817414ff..e206b14364 100644 --- a/src/test/java/com/alibaba/druid/bvt/pool/basic/PoolableStatementTest2.java +++ b/src/test/java/com/alibaba/druid/bvt/pool/basic/PoolableStatementTest2.java @@ -607,4 +607,129 @@ public class PoolableStatementTest2 extends TestCase { conn.close(); } + public void test_getResultSetHoldability() throws Exception { + Connection conn = dataSource.getConnection(); + Statement stmt = conn.createStatement(); + + stmt.getResultSetHoldability(); + ((PoolableStatement) stmt).getStatement().close(); + + { + SQLException error = null; + try { + stmt.getResultSetHoldability(); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + + stmt.close(); + conn.close(); + } + + public void test_execute() throws Exception { + Connection conn = dataSource.getConnection(); + Statement stmt = conn.createStatement(); + + stmt.execute("SELECT 1", new String[0]); + ((PoolableStatement) stmt).getStatement().close(); + + { + SQLException error = null; + try { + stmt.execute("SELECT 1", new String[0]); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + + stmt.close(); + conn.close(); + } + + public void test_execute_1() throws Exception { + Connection conn = dataSource.getConnection(); + Statement stmt = conn.createStatement(); + + stmt.execute("SELECT 1", new int[0]); + ((PoolableStatement) stmt).getStatement().close(); + + { + SQLException error = null; + try { + stmt.execute("SELECT 1", new int[0]); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + + stmt.close(); + conn.close(); + } + + public void test_execute_2() throws Exception { + Connection conn = dataSource.getConnection(); + Statement stmt = conn.createStatement(); + + stmt.execute("SELECT 1", Statement.NO_GENERATED_KEYS); + ((PoolableStatement) stmt).getStatement().close(); + + { + SQLException error = null; + try { + stmt.execute("SELECT 1", Statement.NO_GENERATED_KEYS); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + + stmt.close(); + conn.close(); + } + + public void test_executeUpdate_1() throws Exception { + Connection conn = dataSource.getConnection(); + Statement stmt = conn.createStatement(); + + stmt.executeUpdate("SELECT 1", new String[0]); + ((PoolableStatement) stmt).getStatement().close(); + + { + SQLException error = null; + try { + stmt.execute("SELECT 1", new String[0]); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + + stmt.close(); + conn.close(); + } + + public void test_executeUpdate_2() throws Exception { + Connection conn = dataSource.getConnection(); + Statement stmt = conn.createStatement(); + + stmt.executeUpdate("SELECT 1", new int[0]); + ((PoolableStatement) stmt).getStatement().close(); + + { + SQLException error = null; + try { + stmt.execute("SELECT 1", new int[0]); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + + stmt.close(); + conn.close(); + } }