summaryrefslogtreecommitdiff
path: root/src/interfaces
diff options
context:
space:
mode:
authorDave Cramer2003-12-12 18:05:34 +0000
committerDave Cramer2003-12-12 18:05:34 +0000
commit777acbb34502adca987683aaa795a3fc98b56c2d (patch)
treec0ed6346a96edd7db5290fbb8bf685b3a48fb240 /src/interfaces
parentef6a80431f9546cafd21f3022a27111e4f7d1718 (diff)
fix casting pooled connections to PGStatement problem patch by JariP
Diffstat (limited to 'src/interfaces')
-rw-r--r--src/interfaces/jdbc/org/postgresql/jdbc2/optional/PooledConnectionImpl.java8
-rw-r--r--src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/ConnectionPoolTest.java25
2 files changed, 28 insertions, 5 deletions
diff --git a/src/interfaces/jdbc/org/postgresql/jdbc2/optional/PooledConnectionImpl.java b/src/interfaces/jdbc/org/postgresql/jdbc2/optional/PooledConnectionImpl.java
index 2a5190e0e61..687441fecf6 100644
--- a/src/interfaces/jdbc/org/postgresql/jdbc2/optional/PooledConnectionImpl.java
+++ b/src/interfaces/jdbc/org/postgresql/jdbc2/optional/PooledConnectionImpl.java
@@ -14,7 +14,7 @@ import org.postgresql.PGConnection;
*
* @author Aaron Mulder (ammulder@chariotsolutions.com)
* @author Csaba Nagy (ncsaba@yahoo.com)
- * @version $Revision: 1.7 $
+ * @version $Revision: 1.8 $
*/
public class PooledConnectionImpl implements PooledConnection
{
@@ -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/src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/ConnectionPoolTest.java b/src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/ConnectionPoolTest.java
index caac23d18b2..d49f73c8be9 100644
--- a/src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/ConnectionPoolTest.java
+++ b/src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/ConnectionPoolTest.java
@@ -11,7 +11,7 @@ import java.sql.*;
* interface to the PooledConnection is through the CPDS.
*
* @author Aaron Mulder (ammulder@chariotsolutions.com)
- * @version $Revision: 1.7 $
+ * @version $Revision: 1.8 $
*/
public class ConnectionPoolTest extends BaseDataSourceTest
{
@@ -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