Search code examples
javajdbclog4jdbc

log4jdbc sql timing of both : executing PreparedStatement SELECT + retrieving whole result set


Is there an easy way to measure executiontime of a whole block ? This is a closed code big Java WAR application so I think it is hard to introduce startTime/endTime blocks by some AOP.

// startTime

PreparedStatement prep = ...
ResultSet rs = prep.executeQuery();
// iterate over whole rs

// endTime
// executionTime = endTime - startTime

Assuming a Connection is returned to a db pool after each statement one could use the timing of "Connection in use" time provided by some Java app servers. But I am looking for the easiest solution.


Solution

  • Just to close the question: I added a few lines to log4jdbc code to measure the whole time (since start query to close result set) and log it when above a threshold.