pointcuts for JDBC calls- SQL not printing

shilpa tr
  • shilpa tr

    shilpa tr - 2009-07-16


    I am trying to modify Glassbox source code to monitor JDBC calls.
    The pointcuts for JDBC calls- PreparedStatement, preparestatement(examples is shown in description part) executes for  web application running on weblogic server 9.2,
    but in the corresponding pointcut advice, when I try to print SQL statement.It is not printing SQL statement executed, but prints as follows:
    Result set_statementweblogic.jdbc.wrapper.PreparedStatement_oracle_jdbc_driver_T4CPreparedStatement@35
    prepared statement key=weblogic.jdbc.wrapper.PreparedStatement_oracle_jdbc_driver_T4CPreparedStatement@35
    prepared statement key=weblogic.jdbc.wrapper.PreparedStatement_oracle_jdbc_driver_T4CPreparedStatement@35

    I have added pointcuts to JDBCMonitor.aj source file in Glassbox Source code as follows:
    public pointcut jdbcExecuteQuery(String str) : // direct execute
    call(* java.sql.Statement+.executeQuery(String)) && args(str);

    public pointcut jdbcExecuteUpdate(String str) : // direct update
    call(* java.sql.Statement+.executeUpdate(String))&& args(str);

    public pointcut jdbcExecutePrepare(PreparedStatement stmt) :
    // execute prepared statement stmt
    (call(* java.sql.PreparedStatement.executeUpdate()) || call(* java.sql.PreparedStatement.executeQuery()))
    && target(stmt);

    before(String str): jdbcExecuteQuery( str) { System.out.println(" jdbcExecuteQuery(String str):"+str);}

    before(String str): jdbcExecuteUpdate(str) { System.out.println(" jdbcExecuteUpdate(String str):"+str);}

    after(PreparedStatement stmt):jdbcExecutePrepare(stmt){System.out.println("jdbcExecutePrepare(stmt):"+stmt.toString());}

    Please give me the solution, so that actual SQL statement get's printed in advice, when pointcuts executed - for JDBC calls, during apllication is running.

    Please reply as soon as possible. Help would be highly useful.

    Thanks in advance,
    shilpa tr

    • Ron Bodkin

      Ron Bodkin - 2009-07-21

      Hi There,

      I believe the issue is how aspectj load-time weaving works when you have types loaded by different classloaders. To debug that, try weaving your JDBC driver offline instead of using load-time weaving. If that works, then let's raise a bug for the AspectJ project. Also, try out the latest release of the AspectJ weaver to see if it fixes the problem.



Log in to post a comment.