UndeclaredThrowableException is thrown instead SQLException when using setTransactionRecoveryEnabled(true)

Bug #1311954 reported by Alexey Panteleev
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
BoneCP
New
Undecided
Unassigned

Bug Description

Hello,

 We use the following code in our app to test if a database/catalog exists

 try {
  connection.setCatalog(name);
 }catch(SQLException ex){
// Analyze SQL code here to detect "unknown catalog" error
}

 For some other reasons (stale connections) we've enabled setTransactionRecoveryEnabled(true) mode and that now breaks our catalog testing try/catch. For some reason BoneCP's setCatalog() throws UndeclaredThrowableException instead of SQLException

java.lang.reflect.UndeclaredThrowableException: null
        at com.sun.proxy.$Proxy0.setCatalog(Unknown Source) ~[na:na]
        at com.jolbox.bonecp.ConnectionHandle.setCatalog(ConnectionHandle.java:1305) ~[bonecp-0.8.0.RELEASE.jar:na]
        at
...

Caused by: java.lang.reflect.InvocationTargetException: null
        at sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source) ~[na:na]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_51]
        at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_51]
        at com.jolbox.bonecp.MemorizeTransactionProxy.invoke(MemorizeTransactionProxy.java:233) ~[bonecp-0.8.0.RELEASE.jar:na]
        ... 10 common frames omitted
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown database 'dbname'
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.7.0_51]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) ~[na:1.7.0_51]
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.7.0_51]
        at java.lang.reflect.Constructor.newInstance(Constructor.java:526) ~[na:1.7.0_51]
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) ~[mysql-connector-java-5.1.16.jar:na]
        at com.mysql.jdbc.Util.getInstance(Util.java:386) ~[mysql-connector-java-5.1.16.jar:na]
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052) ~[mysql-connector-java-5.1.16.jar:na]
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3597) ~[mysql-connector-java-5.1.16.jar:na]
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3529) ~[mysql-connector-java-5.1.16.jar:na]
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1990) ~[mysql-connector-java-5.1.16.jar:na]
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2151) ~[mysql-connector-java-5.1.16.jar:na]
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2619) ~[mysql-connector-java-5.1.16.jar:na]
        at com.mysql.jdbc.ConnectionImpl.setCatalog(ConnectionImpl.java:5083) ~[mysql-connector-java-5.1.16.jar:na]
        ... 14 common frames omitted

Any ideas? Can the code be enhanced to throw the original exception?

description: updated
description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.