From 4e64d71c666d3b7aceea9f2f7c506eb12f7048ad Mon Sep 17 00:00:00 2001 From: wenshao Date: Fri, 16 Sep 2011 08:42:41 +0000 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://code.alibabatech.com/svn/druid/trunk@812 b9813039-fb51-4c41-a8b9-e21c2acb5095 --- .../alibaba/druid/pool/PoolableStatement.java | 6 +- .../pool/basic/PoolableStatementTest2.java | 84 +++++++++++++++++++ 2 files changed, 89 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/alibaba/druid/pool/PoolableStatement.java b/src/main/java/com/alibaba/druid/pool/PoolableStatement.java index 62c239849f..5c3b5667f6 100644 --- a/src/main/java/com/alibaba/druid/pool/PoolableStatement.java +++ b/src/main/java/com/alibaba/druid/pool/PoolableStatement.java @@ -505,7 +505,11 @@ public class PoolableStatement extends PoolableWrapper implements Statement { @Override public final void setPoolable(boolean poolable) throws SQLException { - throw new UnsupportedOperationException(); + if (poolable) { + return; + } + + throw new SQLException("not support"); } @Override 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 359bbea48e..908aa7b5ef 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 @@ -931,4 +931,88 @@ public class PoolableStatementTest2 extends TestCase { stmt.close(); conn.close(); } + + public void test_executeUpdate_5() throws Exception { + Connection conn = dataSource.getConnection(); + Statement stmt = conn.createStatement(); + + stmt.executeUpdate("SET 1", Statement.RETURN_GENERATED_KEYS); + ((PoolableStatement) stmt).getStatement().close(); + + { + SQLException error = null; + try { + stmt.executeUpdate("SET 1", Statement.RETURN_GENERATED_KEYS); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + + stmt.close(); + conn.close(); + } + + public void test_executeUpdate_6() throws Exception { + Connection conn = dataSource.getConnection(); + Statement stmt = conn.createStatement(); + + stmt.executeUpdate("SET 1", new String[0]); + ((PoolableStatement) 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(); + } + + public void test_executeUpdate_7() throws Exception { + Connection conn = dataSource.getConnection(); + Statement stmt = conn.createStatement(); + + stmt.executeUpdate("SET 1", new int[0]); + ((PoolableStatement) 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(); + } + + + public void test_setPoolable() throws Exception { + Connection conn = dataSource.getConnection(); + Statement stmt = conn.createStatement(); + + stmt.setPoolable(true); + + { + SQLException error = null; + try { + stmt.setPoolable(false); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + + stmt.close(); + conn.close(); + } }