-->
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.  [ 1 post ] 
Author Message
 Post subject: Broken Pipe => Hibernate + C3P0 + SQL SERVER 2000 + sqljd
PostPosted: Wed Jul 23, 2008 4:11 pm 
Newbie

Joined: Wed Jul 23, 2008 3:26 pm
Posts: 1
Location: France
Hi,

I have a problem for now a long time I tried to solve it using different solutions found on this forum and on the web.

My webapp (Tomcat, JSF, Hibernate) use hibernate for persistence. It have to conect dynamicly to diferent databases hosted on an SQL Server. The session factories are dynamicly created using Java code, not an hibernate.cfg.xml file. The conection parameters are stored in a MySQL database for which an hibernate.cgf.xml exists.

The Session Factories targeted to the SQLServer are stored in a HashMap in an application scoped ManagedBean.

The problem is that, after a while, the app loose the ability to establish new conections to the SQLServer.

When I restart Tomcat, the problem disapear for a while and come back.

I thought that it came from the C3P0 timeout whiwh could be higher than the SQLServer timeout, so I place it from 300 to 45 seconds but the problem still persist.

Hibernate version: 3

Session opening and closing code
Code:
Session sess = hbnSessFacto.getSessFacto(agence.getAgenNom()).openSession();
      try {
         Criteria crit = sess.createCriteria(XXXX.class);
         crit.add(Restrictions.eq("xxxxx", xxxxx));
         crit.setMaxResults(1);
         retour = (XXXX)crit.uniqueResult();
      } catch (HibernateException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
      }finally{
         sess.close();
      }

Session Factories building code :
Code:
curAg=(Agence)it.next();
            conURL = "jdbc:microsoft:sqlserver://"+curAg.getBddServerName()+":1433;databaseName="+curAg.getBddNom();
            curConf = new Configuration();
            curConf.addClass(ns.model.XXXX.class);
            curConf.addClass(ns.model.XXXX.class);
            curConf.addClass(ns.model.XXXX.class);
            curConf.addClass(ns.model.XXXX.class);
            curConf.addClass(ns.model.XXXX.class);
            curConf.addClass(ns.model.XXXX.class);
            curConf.addClass(ns.model.XXXX.class);
            curConf.addClass(ns.model.XXXX.class);
            curConf.addClass(ns.model.XXXX.class);
            curConf.addClass(ns.model.XXXX.class);
            curConf.setProperty("hibernate.connection.driver_class", "com.microsoft.jdbc.sqlserver.SQLServerDriver");
            curConf.setProperty("hibernate.dialect", "org.hibernate.dialect.SQLServerDialect");
            curConf.setProperty("hibernate.connection.url", conURL);
            curConf.setProperty("hibernate.connection.username", curAg.getBddUserName());
            curConf.setProperty("hibernate.connection.password", curAg.getBddacc());
            curConf.setProperty("hibernate.show_sql", "true");
            curConf.setProperty("hibernate.c3p0.timeout", "45");
            curConf.setProperty("hibernate.c3p0.c3p0.min_size", "5");
            curConf.setProperty("hibernate.c3p0.c3p0.max_size", "20");
            curConf.setProperty("hibernate.c3p0.c3p0.max_statements", "50");
            curSessFacto=curConf.buildSessionFactory();
            //curSessFacto = new Configuration().configure(new File(curAg.getAgenceHbnConfFileName()).getPath()).buildSessionFactory();
            cgdSessionFactoryMap.put(curAg.getAgenNom(), curSessFacto);

Full stack trace of any exception that occurs:
Code:
org.hibernate.exception.JDBCConnectionException: could not execute query
        at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:74)
        at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
        at org.hibernate.loader.Loader.doList(Loader.java:2148)
        at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
        at org.hibernate.loader.Loader.list(Loader.java:2024)
        at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
        at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1533)
        at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
        at org.hibernate.impl.CriteriaImpl.uniqueResult(CriteriaImpl.java:305)
        at ns.managers.UserManager.findCgdSalarieByMatricule(UserManager.java:65)
        at ns.beans.UserBean.saveConfigUser(UserBean.java:73)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:129)
        at javax.faces.component.UICommand.broadcast(UICommand.java:86)
        at org.ajax4jsf.framework.ajax.AjaxViewRoot.processEvents(AjaxViewRoot.java:180)
        at org.ajax4jsf.framework.ajax.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:158)
        at org.ajax4jsf.framework.ajax.AjaxViewRoot.processApplication(AjaxViewRoot.java:329)
        at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:343)
        at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:137)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
        at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
        at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:96)
        at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:220)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
        at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.jav                                       a:665)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
        at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
        at java.lang.Thread.run(Thread.java:595)
Caused by: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Broken pipe
        at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
        at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
        at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
        at com.microsoft.jdbc.sqlserver.tds.TDSRPCRequest.submitRequest(Unknown Source)
        at com.microsoft.jdbc.sqlserver.SQLServerImplStatement.execute(Unknown Source)
        at com.microsoft.jdbc.base.BaseStatement.commonExecute(Unknown Source)
        at com.microsoft.jdbc.base.BaseStatement.executeQueryInternal(Unknown Source)
        at com.microsoft.jdbc.base.BasePreparedStatement.executeQuery(Unknown Source)
        at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
        at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
        at org.hibernate.loader.Loader.doQuery(Loader.java:662)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
        at org.hibernate.loader.Loader.doList(Loader.java:2145)
        ... 42 more


Name and version of the database you are using:

SQL server 2000


Thanks for helping!!

_________________
------
Mathieu LE CAIN
Econexia


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

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.