我想创建一个扩展 CallableStatement 对象的子类。我想这样做,以便我可以覆盖 execute 和 executeQuery 方法来跟踪每个 SP 调用的一些指标。
目前我的代码如下所示:
Connection db = poolingDataSource.getConnection();
CallableStatement cstmt = db.prepareCall("{call pSampleStoredProc()}");
ResultSet rs = cstmt.executeQuery();
其中 poolingDataSource 来自 apache commons dbcp 包。我的实现使用 JDBC 连接到 MySQL 数据库。
目前,prepareCall 方法返回一个 com.mysql.jdbc.JDBC4CallableStatement。我希望能够对此进行更改,以便它返回我自己的类,该类扩展了 JDBC4CallableStatement 但覆盖了 execute() 和 executeQuery() 方法。
关于最好的方法的任何想法?