-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: mySQL Timeout Issues
PostPosted: Thu Apr 14, 2005 9:15 am 
Newbie

Joined: Wed Dec 01, 2004 2:08 pm
Posts: 8
Hi,

I am using Hibernate Synchronizer with Tomcat and mySQL.

Everything runs fine, unless, I leave my application unattended for more than 8 h. When I then call my application, it throws a exception as shown below. And will not start up angain, until I restart Tomcat.

Obviously, mySQL cuts after a period of time (8h) the db-connection.

Does somebody know a work-around this problem?

Thanks for your help

Klaus

-------------------------------------------------------------------------
LOG:
Exception in SendPrepList.getTbl. Msg: Could not execute query
net.sf.hibernate.JDBCException: Could not execute query
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1547)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1521)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1513)
at com.dll.database.base._BaseRootDAO.find(_BaseRootDAO.java:224)
at com.dll.database.base._BaseRootDAO.find(_BaseRootDAO.java:212)
at com.dll.webobjects.SendPrepList.doQuery(SendPrepList.java:328)
at com.dll.webobjects.SendPrepList.getTable(SendPrepList.java:175)
at org.apache.jsp.sendPrepare_jsp._jspService(sendPrepare_jsp.java:436)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)
Caused by: java.sql.SQLException: No operations allowed after connection closed.
at com.mysql.jdbc.Connection.checkClosed(Connection.java:2726)
at com.mysql.jdbc.Connection.prepareStatement(Connection.java:1347)
at com.mysql.jdbc.Connection.prepareStatement(Connection.java:1328)
at net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.java:257)
at net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.java:232)
at net.sf.hibernate.impl.BatcherImpl.prepareQueryStatement(BatcherImpl.java:65)
at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:779)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:265)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
at net.sf.hibernate.loader.Loader.list(Loader.java:1024)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:854)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1544)
... 37 more


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 16, 2005 3:35 am 
Newbie

Joined: Wed Dec 01, 2004 2:08 pm
Posts: 8
I found a semi-good work-around for the described problem.

I installed a Thread object in the Tomcat-session, which fires a simple request to the database every 1 hour. That keeps the connection alive and mySQL will not close non-busy connections.

REMARK:
If someone has a better solution, please post this as wll.

Thanks

Klaus

------------ 8< ---------------------------------------


In my "index.jsp":
Code:
if( application.getAttribute( "wakeupDB" ) == null ){
  com.dll.util.WakeupDB wk = new com.dll.util.WakeupDB();
  wk.start();
  application.setAttribute( "wakeupDB", wk );
}





Thread-Object:

Code:
public class WakeupDB extends Thread {

public WakeupDB() {
}

public void run(){

  setPriority( MIN_PRIORITY );
  try {
    _BaseRootDAO.initialize();

      while( ( ! isInterrupted() ) ){
        Thread.sleep( 1*60*60*1000 );
        String s = BaseOptionDAO.getInstance().getCurrency( "CH" );
      }
   
    System.out.println( "WakeupDB finished" );

  }catch (Exception e) {
    e.printStackTrace();
  }
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.