Hello Kees De Kooter,
Please Mention the query and hibernate.cfg.xml properties, you have given
so that we can know little more better the error.
wishes,
Prasad DTR
- Original Message
From: Kees de Kooter kdekoo...@gmail.com
To: Tomcat Users List users@tomcat.apache.org
Sent: Monday, 29 December, 2008 20:50:05
Subject: Re: JPA/Hibernate persistence and MySQL connection timeout
Hi Ken,
Take a look at this page:
http://www.hibernate.org/hib_docs/entitymanager/reference/en/html/configuration.html
As you can see the datasource is obtained using JNDI:
jta-data-sourcejava:/DefaultDS/jta-data-source
Cheers,
Kees de Kooter
http://www.boplicity.net
On Mon, Dec 29, 2008 at 14:41, Ken Bowen kbo...@als.com wrote:
Kees,
Can you point me to a discussion of how to do that?
Thanks,
Ken
On Dec 29, 2008, at 3:42 AM, Kees de Kooter wrote:
Why don't u use the existing datasources for JPA (instead of setting
the hibernate.connection properties)?
Kees
On Mon, Dec 29, 2008 at 00:50, Ken Bowen kbo...@als.com wrote:
Hi All,
I'm using: Tomcat 6.0.18; Mysql 5.0.51a; Java 1.5; Hibernate 3.2; (no
spring)
MyApp utilizes five (5) distinct mysql catalogs (databases).
Originally all 5 were accessed using JDBC/JNDI with Resources that all
look
like this
(in webapps/MyApp/META-INF):
Resource name=jdbc/CATALOGNAME auth=Container
type=javax.sql.DataSource
maxActive=100 maxIdle=30 maxWait=1
username=X password=X
driverClassName=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/CATALOGNAME
validationQuery=select 1
/
Everything worked fine, including the validationQuery to deal with MySQL
closing connections overnight.
Recently I replaced the JDBC access for 3 of the catalogs by use of
JPA/Hibernate persistence,
while leaving the other two catalogs as originally implemented (they
consist
of large tables
containing daily price information; hence not very object-oriented.) The
persistence.xml looks
like this:
persistence-unit name=ctdbPU transaction-type=RESOURCE_LOCAL
providerorg.hibernate.ejb.HibernatePersistence/provider
. lots of class entries like:
classcom.connectedtrading.database.users.AbstractLineitem/class
classcom.connectedtrading.database.users.Lineitem/class
properties
property name=hibernate.connection.driver_class
value=com.mysql.jdbc.Driver /
property name=hibernate.connection.url
value=jdbc:mysql://localhost:3306/CATALOGNAME /
property name=hibernate.connection.username value=X /
property name=hibernate.connection.password value=X /
/properties
/persistence-unit
[Interestingly enough, only one of the 3 CATALOGNAMEs appears.]
Note that I left all 5 of the Resource elements in place in context.xml.
Once again, everything works well, EXCEPT that now when I leave the
system
running overnight and
no accesses occur (it's only in dev mode), in the morning I now get the
exception shown at the
end of this email. It certainly looks like the mysql disconnect
behavior.
As with the JDBC case, repeating the access causes everything to start
working correctly.
The query being submitted is
org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:75)
com.connectedtrading.database.users.UserDAO.findByProperty(UserDAO.java:180)
com.connectedtrading.database.users.UserDAO.findByLogin(UserDAO.java:203)
which is a hibernate query supporting user login.
If anyone on the list has had experience with this issue under
JPA/Hibernate
persistence,
I hope you can give me some pointers to dealing with it.
Thanks much in advance,
Ken Bowen
- The Exception-
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it
from fulfilling this request.
exception
javax.servlet.ServletException: javax.persistence.PersistenceException:
org.hibernate.exception.JDBCConnectionException: could not execute query
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:523)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
javax.persistence.PersistenceException:
org.hibernate.exception.JDBCConnectionException: could not execute query
org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:630)
org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:75)
com.connectedtrading.database.users.UserDAO.findByProperty(UserDAO.java:180)