This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Does anyone know if JAMon currently works with DataSources? The documentation has examples using the DriverManager and my few attempts translate this to a DataSource definition in JBoss have not worked. Anyone done this?
Unfortunately I never fully incorporated DataSources into the code. However, there is a wrapper for DataSources that will monitor them if you can provide a utility method like the following in your code and pass your data source through it. Optionally if you have a utility that has a 'Connection getConnection()' method you could do something similar for the Connection itself.
Sorry about the delay in responding by the way. If there is ever an urgent jamon question it is best to post it on the jamon support forum at sourceforge as it notifies me with an email that someone has a question.
OK Steve, thanks. I'll have a play with the wrapper.
Joined: Jun 26, 2002
Alternatively you can monitor any connection (whether returned from a datasource or some other way) in the following manner. If you have a class that manages your connections that should be easy to add.
Joined: Jun 26, 2002
A little late for you maybe, but here is the info on how to use jamon with DataSources. I tested it with mysql on tomcat. The only file you need to change is context.xml which can either reside in your web app in META-INF/context.xml or in the tomcat conf/context.xml file. context.xml is the only file you will need to change by putting in your own connection info (no changes need to be made to web.xml or server.xml).
One gotcha is that the context.xml file is also often copied into one of the tomcat directories (on my computer conf/Catalina/localhost/appname.xml). Delete this file if you change any info in the context.xml files. If you don't then the server may not see your changes and will be using the old file.
The attached context.xml defines 2 dataSources that use JAMon.