1 Reply Latest reply on Oct 27, 2004 9:20 AM by bill.burke

    Interceptor for java.sql.PreparedStatement

    sushmam

      Hi,

      I need to calculate the time taken for the execution of a sql. Thought of doing this by defining pointcut for the java.sql.PreparedStatement Interface. I'm currently defining the point-cut as given below:

       <bind pointcut="call(void $instanceof{java.sql.PreparedStatement}->execute())">
       <interceptor class="com.apple.ist.rubyservice.aspects.SQLExecutionInterceptor"/>
       </bind>
      


      This is not working. Also, I tried defining a pointcut for the oracle.jdbc.OraclePreparedStatement class (part of classes12.zip, which is in the classpath). This isnt working either.

      Is there any other way to define such a pointcut? Any pointers on this will be greatly appreciated.

      Thanks,
      Sushma


        • 1. Re: Interceptor for java.sql.PreparedStatement
          bill.burke

          Your pointcut expression is incorrect and will not match any methods on PreparedStatement.


          It should be:

          <bind pointcut="call(* $instanceof{java.sql.PreparedStatement}->execute*(..))">
           <interceptor class="com.apple.ist.rubyservice.aspects.SQLExecutionInterceptor"/>
           </bind>
          


          This matches every execute method on PreparedStatement. You'll have to provide the full method pattern to do more fine-grained interception.

          Bill