[libpostgresql-jdbc-java] 09/19: fix casting pooled connections to PGStatement problem patch by JariP

Emmanuel Bourg ebourg-guest at moszumanska.debian.org
Mon Jan 9 10:19:07 UTC 2017


This is an automated email from the git hooks/post-receive script.

ebourg-guest pushed a commit to tag REL7_4_1
in repository libpostgresql-jdbc-java.

commit 66aac588bf2b63469d97cf1ff49b3a426ed3a9ab
Author: Dave Cramer <davec at fastcrypt.com>
Date:   Fri Dec 12 18:06:25 2003 +0000

    fix casting pooled connections to PGStatement problem patch by JariP
---
 .../jdbc2/optional/PooledConnectionImpl.java       |  6 +++---
 .../test/jdbc2/optional/ConnectionPoolTest.java    | 23 ++++++++++++++++++++++
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/org/postgresql/jdbc2/optional/PooledConnectionImpl.java b/org/postgresql/jdbc2/optional/PooledConnectionImpl.java
index 4e7ed71..cfcb5a6 100644
--- a/org/postgresql/jdbc2/optional/PooledConnectionImpl.java
+++ b/org/postgresql/jdbc2/optional/PooledConnectionImpl.java
@@ -266,17 +266,17 @@ public class PooledConnectionImpl implements PooledConnection
             else if(method.getName().equals("createStatement"))
             {
                 Statement st = (Statement)method.invoke(con, args);
-                return Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{Statement.class}, new StatementHandler(this, st));
+                return Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{Statement.class, org.postgresql.PGStatement.class}, new StatementHandler(this, st));
             }
             else if(method.getName().equals("prepareCall"))
             {
                 Statement st = (Statement)method.invoke(con, args);
-                return Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{CallableStatement.class}, new StatementHandler(this, st));
+                return Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{CallableStatement.class, org.postgresql.PGStatement.class}, new StatementHandler(this, st));
             }
             else if(method.getName().equals("prepareStatement"))
             {
                 Statement st = (Statement)method.invoke(con, args);
-                return Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{PreparedStatement.class}, new StatementHandler(this, st));
+                return Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{PreparedStatement.class, org.postgresql.PGStatement.class}, new StatementHandler(this, st));
             }
 			else
 			{
diff --git a/org/postgresql/test/jdbc2/optional/ConnectionPoolTest.java b/org/postgresql/test/jdbc2/optional/ConnectionPoolTest.java
index 5cd92db..29ec3f4 100644
--- a/org/postgresql/test/jdbc2/optional/ConnectionPoolTest.java
+++ b/org/postgresql/test/jdbc2/optional/ConnectionPoolTest.java
@@ -423,6 +423,29 @@ public class ConnectionPoolTest extends BaseDataSourceTest
     }
 
     /**
+     * Ensure that a statement created from a pool can be used
+     * like any other statement in regard to pg extensions.
+     */
+    public void testStatementsProxyPGStatement() {
+	try {
+	    PooledConnection pc = getPooledConnection();
+	    con = pc.getConnection();
+	    
+	    Statement s = con.createStatement();
+	    boolean b = ((org.postgresql.PGStatement)s).isUseServerPrepare();
+
+	    PreparedStatement ps = con.prepareStatement("select 'x'");
+	    b = ((org.postgresql.PGStatement)ps).isUseServerPrepare();
+
+            CallableStatement cs = con.prepareCall("select 'x'");
+	    b = ((org.postgresql.PGStatement)cs).isUseServerPrepare();
+
+	} catch (SQLException e) {
+	    fail(e.getMessage());
+	}
+    }
+
+    /**
 	 * Helper class to remove a listener during event dispatching.
 	 */
 	private class RemoveClose implements ConnectionEventListener

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/libpostgresql-jdbc-java.git



More information about the pkg-java-commits mailing list