aspose file tools*
The moose likes Performance and the fly likes JAMon and DataSources Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "JAMon and DataSources" Watch "JAMon and DataSources" New topic
Author

JAMon and DataSources

Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

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?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
steve souza
Ranch Hand

Joined: Jun 26, 2002
Posts: 861
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.




Here is a link to the JAMonDataSource class.

http://jamonapi.cvs.sourceforge.net/viewvc/jamonapi/jamonapi/src/java/com/jamonapi/proxy/JAMonDataSource.java?revision=1.1&view=markup


http://www.jamonapi.com/ - a fast, free open source performance tuning api.
JavaRanch Performance FAQ
steve souza
Ranch Hand

Joined: Jun 26, 2002
Posts: 861
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.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

OK Steve, thanks. I'll have a play with the wrapper.
steve souza
Ranch Hand

Joined: Jun 26, 2002
Posts: 861
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.

steve souza
Ranch Hand

Joined: Jun 26, 2002
Posts: 861
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.

 
 
subject: JAMon and DataSources