I use JBossAS5 and JDBC to connect database and want to log all JDBC execu开发者_Go百科ted SQL.
The data source is configured to JNDI resource in '-ds.xml' as JBossAS required. I don't want to use DBMS itself to log SQL. In addition, the log operation should be transparent to business logic.My approach: I wrote a proxy Driver class which implements java.sql.Driver
and delegates the real driver class underlying. Then the proxy Driver is registered in -ds.xml.
log4jdbc seems to be the current best-of-breed for this sort of thing, although I haven't tried it with JBoss's datasource descriptors yet.
Give it a try.
You really don't want to implement this yourself, though. There are a LOT of interfaces in JDBC that you'd need to implement.
精彩评论