public static PreparedStatement newInstance(PreparedStatement stmt, Log statementLog, int queryStack) {
    InvocationHandler handler = new PreparedStatementLogger(stmt, statementLog, queryStack);
    ClassLoader cl = PreparedStatement.class.getClassLoader();
    return (PreparedStatement) Proxy.newProxyInstance(cl, new Class[]{PreparedStatement.class, CallableStatement.class}, handler);
  }
PreparedStatement proxy to add logging

@author Clinton Begin
@author Eduardo Macarron
src/main/java/org/apache/ibatis/logging/jdbc/PreparedStatementLogger.java