diff --git a/hikaricp-java6/src/main/java/com/zaxxer/hikari/proxy/JavassistProxyFactory.java b/hikaricp-java6/src/main/java/com/zaxxer/hikari/proxy/JavassistProxyFactory.java index c3cad8f1..8f6fa0e9 100644 --- a/hikaricp-java6/src/main/java/com/zaxxer/hikari/proxy/JavassistProxyFactory.java +++ b/hikaricp-java6/src/main/java/com/zaxxer/hikari/proxy/JavassistProxyFactory.java @@ -81,15 +81,15 @@ public final class JavassistProxyFactory try { // Connection is special, it has a checkClosed() call at the beginning - String methodBody = "{ checkClosed(); try { return delegate.method($$); } catch (SQLException e) { checkException(e); throw e;} }"; + String methodBody = "{ checkClosed(); try { return delegate.method($$); } catch (SQLException e) { throw checkException(e); } }"; generateProxyClass(Connection.class, ConnectionProxy.class, methodBody); // Cast is not needed for these - methodBody = "{ try { return delegate.method($$); } catch (SQLException e) { checkException(e); throw e;} }"; + methodBody = "{ try { return delegate.method($$); } catch (SQLException e) { throw checkException(e); } }"; generateProxyClass(Statement.class, StatementProxy.class, methodBody); // For these we have to cast the delegate - methodBody = "{ try { return ((cast) delegate).method($$); } catch (SQLException e) { checkException(e); throw e;} }"; + methodBody = "{ try { return ((cast) delegate).method($$); } catch (SQLException e) { throw checkException(e); } }"; generateProxyClass(PreparedStatement.class, PreparedStatementProxy.class, methodBody); generateProxyClass(CallableStatement.class, CallableStatementProxy.class, methodBody); } diff --git a/hikaricp-java6/src/main/java/com/zaxxer/hikari/proxy/StatementProxy.java b/hikaricp-java6/src/main/java/com/zaxxer/hikari/proxy/StatementProxy.java index 8f36e465..446b7ef1 100644 --- a/hikaricp-java6/src/main/java/com/zaxxer/hikari/proxy/StatementProxy.java +++ b/hikaricp-java6/src/main/java/com/zaxxer/hikari/proxy/StatementProxy.java @@ -40,6 +40,11 @@ public abstract class StatementProxy implements Statement this.delegate = statement; } + protected final SQLException checkException(SQLException e) + { + return connection.checkException(e); + } + // ********************************************************************** // Overridden java.sql.Statement Methods // ********************************************************************** diff --git a/hikaricp/src/main/java/com/zaxxer/hikari/proxy/JavassistProxyFactory.java b/hikaricp/src/main/java/com/zaxxer/hikari/proxy/JavassistProxyFactory.java index 75d8ff47..f50751a3 100644 --- a/hikaricp/src/main/java/com/zaxxer/hikari/proxy/JavassistProxyFactory.java +++ b/hikaricp/src/main/java/com/zaxxer/hikari/proxy/JavassistProxyFactory.java @@ -81,15 +81,15 @@ public final class JavassistProxyFactory try { // Connection is special, it has a checkClosed() call at the beginning - String methodBody = "{ checkClosed(); try { return delegate.method($$); } catch (SQLException e) { checkException(e); throw e;} }"; + String methodBody = "{ checkClosed(); try { return delegate.method($$); } catch (SQLException e) { throw checkException(e); } }"; generateProxyClass(Connection.class, ConnectionProxy.class, methodBody); // Cast is not needed for these - methodBody = "{ try { return delegate.method($$); } catch (SQLException e) { checkException(e); throw e;} }"; + methodBody = "{ try { return delegate.method($$); } catch (SQLException e) { throw checkException(e); } }"; generateProxyClass(Statement.class, StatementProxy.class, methodBody); // For these we have to cast the delegate - methodBody = "{ try { return ((cast) delegate).method($$); } catch (SQLException e) { checkException(e); throw e;} }"; + methodBody = "{ try { return ((cast) delegate).method($$); } catch (SQLException e) { throw checkException(e); } }"; generateProxyClass(PreparedStatement.class, PreparedStatementProxy.class, methodBody); generateProxyClass(CallableStatement.class, CallableStatementProxy.class, methodBody); } diff --git a/hikaricp/src/main/java/com/zaxxer/hikari/proxy/StatementProxy.java b/hikaricp/src/main/java/com/zaxxer/hikari/proxy/StatementProxy.java index 8f36e465..446b7ef1 100644 --- a/hikaricp/src/main/java/com/zaxxer/hikari/proxy/StatementProxy.java +++ b/hikaricp/src/main/java/com/zaxxer/hikari/proxy/StatementProxy.java @@ -40,6 +40,11 @@ public abstract class StatementProxy implements Statement this.delegate = statement; } + protected final SQLException checkException(SQLException e) + { + return connection.checkException(e); + } + // ********************************************************************** // Overridden java.sql.Statement Methods // **********************************************************************