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

193 Views Asked by At

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.

1

There are 1 best solutions below

0
On BEST ANSWER

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.