No Sql Statistics with Tomcat, MySql and Hibernate

634 views
Skip to first unread message

Shane

unread,
Feb 10, 2010, 9:01:41 PM2/10/10
to javamelody
Hi

I have setup a web application in Tomcat with Javamelody and MySql
with Hibernate. I am able to see the JDBC connection details under
system info so I know that JavaMelody is able to connect to the
database. I have executed select/update statements from my application
but nothing is ever shown on the monitoring page under "Statistics
Sql". I have executed "show full processlist" using the same user as
my database connection and it works fine. I can't work out what I am
doing wrong.

Any Ideas?

Thanks,
Shane

evernat

unread,
Feb 11, 2010, 3:37:16 AM2/11/10
to javamelody
Hi Shane,

How is configured jdbc in your hibernate.cfg.xml ?
Can you give a copy of this configuration ?

Thanks, Emeric

Shane

unread,
Feb 11, 2010, 9:01:44 AM2/11/10
to javamelody
Hi Emeric,

Thanks for your help. Here is my configuration which is specified at
run time (could this be the problem?):

AnnotationConfiguration config = new AnnotationConfiguration();

config.setProperty("hibernate.dialect",
"org.hibernate.dialect.HSQLDialect");
config.setProperty("hibernate.connection.datasource", "java:/comp/env/
jdbc/<my db>");
config.setProperty("hibernate.connection.driver",
"com.mysql.jdbc.Driver");
config.setProperty("hibernate.connection.autocommit", "true");
config.setProperty("hibernate.connection.autoreconnect", "true");
config.setProperty("hibernate.connection.wait_timeout", "604800"); //
1 week
config.setProperty("hibernate.cache.provider_class",
"org.hibernate.cache.NoCacheProvider");
config.setProperty("hibernate.hbm2ddl.auto", "update");
config.setProperty("hibernate.show_sql", "false");
config.setProperty("hibernate.transaction.factory_class",
"org.hibernate.transaction.JDBCTransactionFactory");
config.setProperty("hibernate.current_session_context_class",
"thread");

config.setProperty("hibernate.c3p0.min_size","5");
config.setProperty("hibernate.c3p0.max_size","20");
config.setProperty("hibernate.c3p0.timeout","1800");
config.setProperty("hibernate.c3p0.max_statements","50");

> > Shane- Hide quoted text -
>
> - Show quoted text -

evernat

unread,
Feb 11, 2010, 2:19:06 PM2/11/10
to javamelody
Hi,

I do not understand why you have both hibernate.connection.datasource
and hibernate.connection.driver / hibernate.c3p0.*
because if you have a jndi datasource you don't need to specify in
hibernate a jdbc driver and c3p0.

To make it work first with a jdbc driver, I think that you can :
- remove the line with hibernate.connection.datasource
- add config.setProperty("hibernate.connection.driver_class",
"net.bull.javamelody.JdbcDriver");
(you have already added :
config.setProperty("hibernate.connection.driver",
"com.mysql.jdbc.Driver"); )
- and add
config.setProperty("hibernate.connection.url", "jdbc:mysql://
localhost:3306/<myschema>");
config.setProperty("hibernate.connection.username",
"<myuser>");
config.setProperty("hibernate.connection.password",
"<mypassword>");

If it works you could also use a jndi datasource :
- remove lines with hibernate.connection.driver_class,
hibernate.connection.driver and hibernate.c3p0,
hibernate.connection.url, hibernate.connection.username,
hibernate.connection.password
- add config.setProperty("hibernate.connection.datasource", "java:/
comp/env/jdbc/<my db>");


And for information, the following line is in general a very bad
idea :


config.setProperty("hibernate.connection.autocommit", "true")

See UserGuide for more details on jdbc with JavaMelody :
http://code.google.com/p/javamelody/wiki/UserGuide#7._JDBC

bye, Emeric

Reply all
Reply to author
Forward
0 new messages