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

Commit9db065b

Browse files
author
Barry Lind
committed
Patch from Aaron Mulder to have pooled connections implement PGConnection
Modified Files: jdbc/org/postgresql/jdbc2/optional/PooledConnectionImpl.java jdbc/org/postgresql/test/jdbc2/optional/BaseDataSourceTest.java
1 parent88e5240 commit9db065b

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
importjava.sql.*;
55
importjava.util.*;
66
importjava.lang.reflect.*;
7+
importorg.postgresql.PGConnection;
78

89
/**
910
* PostgreSQL implementation of the PooledConnection interface. This shouldn't
@@ -12,7 +13,7 @@
1213
* @see ConnectionPool
1314
*
1415
* @author Aaron Mulder (ammulder@chariotsolutions.com)
15-
* @version $Revision: 1.5 $
16+
* @version $Revision: 1.6 $
1617
*/
1718
publicclassPooledConnectionImplimplementsPooledConnection
1819
{
@@ -114,7 +115,7 @@ public Connection getConnection() throws SQLException
114115
con.setAutoCommit(autoCommit);
115116
ConnectionHandlerhandler =newConnectionHandler(con);
116117
last =handler;
117-
Connectioncon = (Connection)Proxy.newProxyInstance(getClass().getClassLoader(),newClass[]{Connection.class},handler);
118+
Connectioncon = (Connection)Proxy.newProxyInstance(getClass().getClassLoader(),newClass[]{Connection.class,PGConnection.class},handler);
118119
last.setProxy(con);
119120
returncon;
120121
}
@@ -213,7 +214,7 @@ public Object invoke(Object proxy, Method method, Object[] args)
213214
throwe.getTargetException();
214215
}
215216
}
216-
// All the rest is from the Connection interface
217+
// All the rest is from the Connectionor PGConnectioninterface
217218
if (method.getName().equals("isClosed"))
218219
{
219220
returncon ==null ?Boolean.TRUE :Boolean.FALSE;

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
importjunit.framework.TestCase;
44
importorg.postgresql.test.TestUtil;
55
importorg.postgresql.jdbc2.optional.BaseDataSource;
6+
importorg.postgresql.PGConnection;
67

78
importjava.sql.*;
89
importjava.util.*;
@@ -16,7 +17,7 @@
1617
* tests.
1718
*
1819
* @author Aaron Mulder (ammulder@chariotsolutions.com)
19-
* @version $Revision: 1.4 $
20+
* @version $Revision: 1.5 $
2021
*/
2122
publicabstractclassBaseDataSourceTestextendsTestCase
2223
{
@@ -179,6 +180,24 @@ public void testNotPooledConnection()
179180
}
180181
}
181182

183+
/**
184+
* Test to make sure that PGConnection methods can be called on the
185+
* pooled Connection.
186+
*/
187+
publicvoidtestPGConnection()
188+
{
189+
try
190+
{
191+
con =getDataSourceConnection();
192+
((PGConnection)con).getEncoding().name();
193+
con.close();
194+
}
195+
catch (Exceptione)
196+
{
197+
fail("Unable to call PGConnection method on pooled connection due to "+e.getClass().getName()+" ("+e.getMessage()+")");
198+
}
199+
}
200+
182201
/**
183202
* Uses the mini-JNDI implementation for testing purposes
184203
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp