How can I see when my pooling library (C3P0) is creating and closing JDBC connections?
Note: I have done research on this and already found a solution. I'm posting it here so that it may be useful to others and I can refer back to it in case I forget it in future.
Other approaches/answers are welcome.
log4jdbc
library can be used to log JDBC connections. Add this library to POM -Configure
log4j.properties
. Modify logging options to adjust the level of details as per your own needs.Configure a data source.
Notes on the above data source config:
net.sf.log4jdbc.DriverSpy
jdbc:log4jdbc
. So if you use Oracle, your JDBC URL will now begin withjdbc:log4jdbc:oracle
.Now the log messages would appear on screen -
Some Mysql commands to show connection details -