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

Commite2ad581

Browse files
author
Dave Cramer
committed
mike beachy's patch for statement handling
1 parent83feff3 commite2ad581

File tree

2 files changed

+82
-4
lines changed

2 files changed

+82
-4
lines changed

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* @see ConnectionPool
1313
*
1414
* @author Aaron Mulder (ammulder@chariotsolutions.com)
15-
* @version $Revision: 1.4 $
15+
* @version $Revision: 1.5 $
1616
*/
1717
publicclassPooledConnectionImplimplementsPooledConnection
1818
{
@@ -204,7 +204,14 @@ public Object invoke(Object proxy, Method method, Object[] args)
204204
returnBoolean.FALSE;
205205
}
206206
}
207-
returnmethod.invoke(con,args);
207+
try
208+
{
209+
returnmethod.invoke(con,args);
210+
}
211+
catch (InvocationTargetExceptione)
212+
{
213+
throwe.getTargetException();
214+
}
208215
}
209216
// All the rest is from the Connection interface
210217
if (method.getName().equals("isClosed"))
@@ -355,7 +362,14 @@ else if (method.getName().equals("getConnection"))
355362
}
356363
else
357364
{
358-
returnmethod.invoke(st,args);
365+
try
366+
{
367+
returnmethod.invoke(st,args);
368+
}
369+
catch (InvocationTargetExceptione)
370+
{
371+
throwe.getTargetException();
372+
}
359373
}
360374
}
361375
}

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

Lines changed: 65 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.4 $
14+
* @version $Revision: 1.5 $
1515
*/
1616
publicclassConnectionPoolTestextendsBaseDataSourceTest
1717
{
@@ -359,6 +359,70 @@ public void testStatementConnection() {
359359
}
360360
}
361361

362+
/**
363+
* Ensures that the Statement proxy generated by the Connection handle
364+
* throws the correct kind of exception.
365+
*/
366+
publicvoidtestStatementProxy() {
367+
Statements =null;
368+
try
369+
{
370+
PooledConnectionpc =getPooledConnection();
371+
Connectioncon =pc.getConnection();
372+
s =con.createStatement();
373+
}
374+
catch (SQLExceptione)
375+
{
376+
fail(e.getMessage());
377+
}
378+
try
379+
{
380+
s.executeQuery("SELECT * FROM THIS_TABLE_SHOULD_NOT_EXIST");
381+
fail("An SQL exception was not thrown that should have been");
382+
}
383+
catch (SQLExceptione)
384+
{
385+
;// This is the expected and correct path
386+
}
387+
catch (Exceptione)
388+
{
389+
fail("bad exception; was expecting SQLException, not" +
390+
e.getClass().getName());
391+
}
392+
}
393+
394+
/**
395+
* Ensures that the Statement proxy generated by the Connection handle
396+
* throws the correct kind of exception.
397+
*/
398+
publicvoidtestStatementProxy() {
399+
Statements =null;
400+
try
401+
{
402+
PooledConnectionpc =getPooledConnection();
403+
Connectioncon =pc.getConnection();
404+
s =con.createStatement();
405+
}
406+
catch (SQLExceptione)
407+
{
408+
fail(e.getMessage());
409+
}
410+
try
411+
{
412+
s.executeQuery("SELECT * FROM THIS_TABLE_SHOULD_NOT_EXIST");
413+
fail("An SQL exception was not thrown that should have been");
414+
}
415+
catch (SQLExceptione)
416+
{
417+
;// This is the expected and correct path
418+
}
419+
catch (Exceptione)
420+
{
421+
fail("bad exception; was expecting SQLException, not" +
422+
e.getClass().getName());
423+
}
424+
}
425+
362426
/**
363427
* Ensures that a prepared statement generated by a proxied connection
364428
* returns the proxied connection from getConnection() [not the physical

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp