2 Replies Latest reply on Sep 14, 2009 2:31 AM by joachimhb

    Instrumenting SQL execution times (Statement and PreparedSta

      Hello,

      Does anyone have any clues as to how its possible to instrument JDBC SQL query times ? I have successfully been able to instrument other classes, but I am unable to find the class that actually executes the Query.

      I have tried, for each class loaded in the classloader, to looks at its implementations to check if one the class implements either java.sql.Statement or java.sql.PreparedStatement. If thats not the case, I check the superclass for up to 10 levels. The application uses DBCP, and the following classes gets instrumented:

      java.sql.PreparedStatement
      java.sql.CallableStatement
      org.apache.commons.dbcp.DelegatingPreparedStatement
      org.apache.commons.dbcp.DelegatingStatement
      org.apache.derby.iapi.jdbc.EnginePreparedStatement
      org.apache.derby.iapi.jdbc.EngineStatement

      However, none of these classes seems to fire off the actual execute(), executeQuery() or executeUpdate methods - at least the instrumentation times do not get returned as expected.

      Is there a good strategy to be able to instrument JDBC ? My main goal here is to be able to store the execution times per. SQL that is ran through the system.