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.