Source:
public Object invoke( Object proxy, Method method, Object[] args ) throws Throwable { Object o = null; try { o = method.invoke( connection, args ); } catch ( Throwable t ) { if ( t instanceof InvocationTargetException ) { Throwable cause = t.getCause(); if ( cause instanceof SQLException ) { String methodName = method.getName(); if ( cause.getMessage().equals( "Method not supported" ) || cause.getMessage().equals( "Method not supported - setAutoCommit(false)" )) { if ( "createStatement".equals( methodName ) ) { o = createStatement( connection, args ); } else if ( "isReadOnly".equals( methodName ) ) { o = Boolean.FALSE; } else if ( "setReadOnly".equals( methodName ) ) { o = (Void) null; } else if ( "setAutoCommit".equals( methodName ) ) { o = (Void) null; } else { throw cause; } } else { throw cause; } } else { throw cause; } } else { throw t; } } if ( o instanceof DatabaseMetaData ) { DatabaseMetaData dbmd = (DatabaseMetaData) o; return (DatabaseMetaData) Proxy.newProxyInstance( dbmd.getClass().getClassLoader(), new Class[] { DatabaseMetaData.class }, new DatabaseMetaDataInvocationHandler( dbmd, this ) ); } else if ( o instanceof PreparedStatement ) { PreparedStatement st = (PreparedStatement) o; return (PreparedStatement) Proxy.newProxyInstance( st.getClass().getClassLoader(), new Class[] { PreparedStatement.class }, new CaptureResultSetInvocationHandler<PreparedStatement>( st ) ); } else if ( o instanceof Statement ) { Statement st = (Statement) o; return (Statement) Proxy.newProxyInstance( st.getClass().getClassLoader(), new Class[] { Statement.class }, new CaptureResultSetInvocationHandler<Statement>( st ) ); } else { return o; } }

Target:
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { Object o = null; try { o = method.invoke(connection, args); } catch(Throwable t) { if(t instanceof InvocationTargetException) { Throwable cause = t.getCause(); if(cause instanceof SQLException) { String methodName = method.getName(); if(cause.getMessage().startsWith("Method not supported") || cause.getMessage().equals("enabling autocommit is not supported")) { if("createStatement".equals(methodName)) { o = createStatement(connection,args); } else if("isReadOnly".equals(methodName)) { o = Boolean.FALSE; } else if("setReadOnly".equals(methodName)) { o = (Void)null; } else { throw cause; } } else throw cause; } else { throw cause; } } else { throw t; } } if(o instanceof DatabaseMetaData) { DatabaseMetaData dbmd = (DatabaseMetaData)o; return (DatabaseMetaData)Proxy.newProxyInstance(dbmd.getClass().getClassLoader(), new Class[] { DatabaseMetaData.class }, new DatabaseMetaDataInvocationHandler(dbmd, this)); } else if(o instanceof PreparedStatement) { PreparedStatement st = (PreparedStatement)o; return (PreparedStatement)Proxy.newProxyInstance(st.getClass().getClassLoader(), new Class[] { PreparedStatement.class }, new CaptureResultSetInvocationHandler<PreparedStatement>(st)); } else if(o instanceof Statement) { Statement st = (Statement)o; return (Statement)Proxy.newProxyInstance(st.getClass().getClassLoader(), new Class[] { Statement.class }, new CaptureResultSetInvocationHandler<Statement>(st)); } else { return o; } }