Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit777acbb

Browse files
author
Dave Cramer
committed
fix casting pooled connections to PGStatement problem patch by JariP
1 parentef6a804 commit777acbb

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

‎src/interfaces/jdbc/org/postgresql/jdbc2/optional/PooledConnectionImpl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*
1515
* @author Aaron Mulder (ammulder@chariotsolutions.com)
1616
* @author Csaba Nagy (ncsaba@yahoo.com)
17-
* @version $Revision: 1.7 $
17+
* @version $Revision: 1.8 $
1818
*/
1919
publicclassPooledConnectionImplimplementsPooledConnection
2020
{
@@ -266,17 +266,17 @@ public Object invoke(Object proxy, Method method, Object[] args)
266266
elseif(method.getName().equals("createStatement"))
267267
{
268268
Statementst = (Statement)method.invoke(con,args);
269-
returnProxy.newProxyInstance(getClass().getClassLoader(),newClass[]{Statement.class},newStatementHandler(this,st));
269+
returnProxy.newProxyInstance(getClass().getClassLoader(),newClass[]{Statement.class,org.postgresql.PGStatement.class},newStatementHandler(this,st));
270270
}
271271
elseif(method.getName().equals("prepareCall"))
272272
{
273273
Statementst = (Statement)method.invoke(con,args);
274-
returnProxy.newProxyInstance(getClass().getClassLoader(),newClass[]{CallableStatement.class},newStatementHandler(this,st));
274+
returnProxy.newProxyInstance(getClass().getClassLoader(),newClass[]{CallableStatement.class,org.postgresql.PGStatement.class},newStatementHandler(this,st));
275275
}
276276
elseif(method.getName().equals("prepareStatement"))
277277
{
278278
Statementst = (Statement)method.invoke(con,args);
279-
returnProxy.newProxyInstance(getClass().getClassLoader(),newClass[]{PreparedStatement.class},newStatementHandler(this,st));
279+
returnProxy.newProxyInstance(getClass().getClassLoader(),newClass[]{PreparedStatement.class,org.postgresql.PGStatement.class},newStatementHandler(this,st));
280280
}
281281
else
282282
{

‎src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/ConnectionPoolTest.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* interface to the PooledConnection is through the CPDS.
1212
*
1313
* @author Aaron Mulder (ammulder@chariotsolutions.com)
14-
* @version $Revision: 1.7 $
14+
* @version $Revision: 1.8 $
1515
*/
1616
publicclassConnectionPoolTestextendsBaseDataSourceTest
1717
{
@@ -422,6 +422,29 @@ public void testCallableStatementConnection() {
422422
}
423423
}
424424

425+
/**
426+
* Ensure that a statement created from a pool can be used
427+
* like any other statement in regard to pg extensions.
428+
*/
429+
publicvoidtestStatementsProxyPGStatement() {
430+
try {
431+
PooledConnectionpc =getPooledConnection();
432+
con =pc.getConnection();
433+
434+
Statements =con.createStatement();
435+
booleanb = ((org.postgresql.PGStatement)s).isUseServerPrepare();
436+
437+
PreparedStatementps =con.prepareStatement("select 'x'");
438+
b = ((org.postgresql.PGStatement)ps).isUseServerPrepare();
439+
440+
CallableStatementcs =con.prepareCall("select 'x'");
441+
b = ((org.postgresql.PGStatement)cs).isUseServerPrepare();
442+
443+
}catch (SQLExceptione) {
444+
fail(e.getMessage());
445+
}
446+
}
447+
425448
/**
426449
* Helper class to remove a listener during event dispatching.
427450
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp