I want to create a subclass that extends the CallableStatement object. I want to do this so I can override the execute and executeQuery methods to track some metrics on each SP call.
Currently I have code that looks like this:
Connection db = poolingDataSource.getConnection();
CallableStatement cstmt = db.prepareCall("{call pSampleStoredProc()}");
ResultSet rs = cstmt.executeQuery();
where poolingDataSource is from the apache commons dbcp package. My implementation is hooked into a MySQL database using JDBC.
Currently, the prepareCall method returns a com.mysql.jdbc.JDBC4CallableStatement. I'd like to be able to change this so that it returns a class of my own that extends JDBC4CallableStatement but overrides the execute() and executeQuery() methods.
Any ideas about the best way to do this?