-->
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.  [ 6 posts ] 
Author Message
 Post subject: problem with connection automaticly closed
PostPosted: Wed Dec 13, 2006 11:47 am 
Newbie

Joined: Wed Dec 13, 2006 6:48 am
Posts: 7
hello

HIBERNATE 3.2

I execute two programmes connecting to a sybase bd.

this is a connection code
Code:
   
          try{
              sessions = cdb.Config().buildSessionFactory();             
              session = sessions.openSession(); // open a new Session         
         }catch(java.lang.Exception exception){log.ecritLigne(exception.toString());}
   
         while (notStop()) {
       
            Shecduler(); //procedure utilisant la même connection
           
            try {
              this.sleep(1000);
            }
            catch (java.lang.Throwable tr) {log.ecritLigne(tr.toString());}
       
          }
     


that what is dowing the function Shecduler()
Code:
      List list =null;
      ArrayList processId = new ArrayList();
      ArrayList InterfaceId = new ArrayList();
      ArrayList CycleDay = new ArrayList();
      ArrayList CycleHour = new ArrayList();
      ArrayList CycleMinute = new ArrayList();
      ArrayList LastLap = new ArrayList();
      ArrayList Modules = new ArrayList();
     
      try{     
           session.beginTransaction();     
           list = session.createSQLQuery("select ProcessId,ProcessCode,moduleId,CycleDay,CycleHour,CycleMinute,LastLap from  B_scheduler where ProcessChecked=1").list();
           session.clear();
           session.flush();
      } catch (Exception e) {System.out.println(e.getMessage()); }
     
      Iterator iter =list.iterator();
      for(Iterator it=iter; it.hasNext();)
      {
        Object[] row = (Object[]) iter.next();
        processId.add(row[0]);   
        InterfaceId.add(row[1]);       
        Modules.add(row[2]);       
        CycleDay.add(row[3]);       
        CycleHour.add(row[4]);       
        CycleMinute.add(row[5]);       
        LastLap.add(row[6]);         
      }   


and this is the configuration
Code:
     org.hibernate.cfg.Configuration cfg = new org.hibernate.cfg.Configuration()
     .setProperty("hibernate.connection.driver_class",Driver)
     .setProperty("hibernate.dialect", Dialect)
     .setProperty("hibernate.connection.url", Url)
     .setProperty("hibernate.connection.user",user)
     .setProperty("hibernate.show_sql","true")
     .setProperty("hibernate.connection.password",pass)
     .setProperty("hibernate.transaction.factory_class","org.hibernate.transaction.JDBCTransactionFactory")
     .setProperty("hibernate.c3p0.min_size","5")
     .setProperty("hibernate.c3p0.max_size","10")
     .setProperty("hibernate.c3p0.timeout","0")
     .setProperty("hibernate.c3p0.max_statements","0")
     .addResource("CMPI_Messagedetails.hbm.xml"); 


the second programme loose the connection after somme min , but the first continou.

thas is what i have on the return

Code:
Exception in thread "Thread-0"
org.hibernate.exception.GenericJDBCException: Cannot open connection
   at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
   at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:420)
   at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)
   at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:119)
   at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:57)
   at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1326)
   at smartidebpm.SchedulerBPM.Shecduler(SchedulerBPM.java:72)
   at smartidebpm.SchedulerBPM.run(SchedulerBPM.java:48)
Caused by: java.sql.SQLException: JZ006: IOException détectée : com.sybase.jdbc2.jdbc.SybConnectionDeadException: JZ0C0: Connexion déjà fermée.
   at com.sybase.jdbc2.jdbc.ErrorMessage.createIOEKilledConnEx(ErrorMessage.java:772)
   at com.sybase.jdbc2.jdbc.ErrorMessage.raiseErrorCheckDead(ErrorMessage.java:813)
   at com.sybase.jdbc2.tds.Tds.handleIOE(Tds.java:3491)
   at com.sybase.jdbc2.tds.Tds.nextResult(Tds.java:2043)
   at com.sybase.jdbc2.jdbc.ResultGetter.nextResult(ResultGetter.java:69)
   at com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:220)
   at com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:203)
   at com.sybase.jdbc2.jdbc.SybStatement.queryLoop(SybStatement.java:1596)
   at com.sybase.jdbc2.jdbc.SybStatement.executeQuery(SybStatement.java:1581)
   at com.sybase.jdbc2.jdbc.SybPreparedStatement.executeQuery(SybPreparedStatement.java:96)
   at com.sybase.jdbc2.tds.Tds.getBoolOption(Tds.java:1292)
   at com.sybase.jdbc2.jdbc.SybConnection.getAutoCommit(SybConnection.java:1013)
   at com.mchange.v2.c3p0.impl.NewProxyConnection.getAutoCommit(NewProxyConnection.java:860)
   at org.hibernate.connection.C3P0ConnectionProvider.getConnection(C3P0ConnectionProvider.java:37)
   at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:417)
   ... 6 more



what i'am douing wrang.

can you help me, please.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 13, 2006 12:14 pm 
Regular
Regular

Joined: Wed Mar 23, 2005 8:43 am
Posts: 105
Location: Moscow, Russia
Why didn't commit the transaction?

_________________
Best Regards


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 13, 2006 12:44 pm 
Newbie

Joined: Wed Dec 13, 2006 6:48 am
Posts: 7
sorry that was just a mistake when copying the code to the topic.

Code:
      List list =null;
      ArrayList processId = new ArrayList();
      ArrayList InterfaceId = new ArrayList();
      ArrayList CycleDay = new ArrayList();
      ArrayList CycleHour = new ArrayList();
      ArrayList CycleMinute = new ArrayList();
      ArrayList LastLap = new ArrayList();
      ArrayList Modules = new ArrayList();
     
      try{     
           session.beginTransaction();     
           list = session.createSQLQuery("select ProcessId,ProcessCode,moduleId,CycleDay,CycleHour,CycleMinute,LastLap from  B_scheduler where ProcessChecked=1").list();
           session.clear();
           session.flush();
           session.getTransaction().commit();
      } catch (Exception e) {System.out.println(e.getMessage()); }
     
      Iterator iter =list.iterator();
      for(Iterator it=iter; it.hasNext();)
      {
        Object[] row = (Object[]) iter.next();
        processId.add(row[0]);   
        InterfaceId.add(row[1]);       
        Modules.add(row[2]);       
        CycleDay.add(row[3]);       
        CycleHour.add(row[4]);       
        CycleMinute.add(row[5]);       
        LastLap.add(row[6]);         
      }   


thanks for answer


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 13, 2006 2:12 pm 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
Don't you use a connection pool or something that could test the connection state before giving it to you ?

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 14, 2006 5:49 am 
Newbie

Joined: Wed Dec 13, 2006 6:48 am
Posts: 7
thank your for answering
the connection exists, the program carries out the selects, but after certain time, there stopped of it even, just in the case of two programs or more opened at the same time .


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 14, 2006 12:36 pm 
Newbie

Joined: Wed Dec 13, 2006 6:48 am
Posts: 7
the problem is always not solved!!!!!!

i don't understand , i cant make connection to my db with more than process.
in the program i have one connectionfactory and one session, i dont close the session, but i clear it each time i used, just if the user decide to stop the program then i close the session, because the program is a timer.

if i lunch 2 process with this program, the second one , after few minutes can't acces to the database and the connection stoped, that is like the first one make concurence to the second.

before i made same thing with program connecting only with jdbc, i did'nt have this problem

what i do wrang with the configuration of hibernate, sure that i don't understand something, but what?

if anybody can give me an explication, that will be fantastic.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.