Hello. I have got a problem with a transaction. Thi is an extracted of the code I have. It works when I test it with some data. But in production environment, since there are a lot of data the method "exportData(...)" takes a lot of time to execute. Hours. It reads data from the session and then produce an excel file as output.
Session session = HibernateUtil.getSession(); try { session.beginTransaction(); exportData(session, ....other parameters....);
try { Helper.rollbackTransaction(session); } catch (Exception e) { } } catch (Exception e) { Helper.logException(LOGGER, signature, e, e.getMessage()); } finally { Helper.rollbackTransaction(session); }
The erorr is this: 2014-02-05 21:59:18,366 ERROR [Timer-0]: (JDBCTransaction.java:198) JDBCTransaction - JDBC rollback failed com.ibm.db2.jcc.a.DisconnectException: A communication error has been detected. Communication protocol being used: Reply.fill(). Communication API being used: InputStream.read(). Location where the error was detected: Read timed out. Communication function detecting the error: *. Protocol specific error codes(s) TCP/IP SOCKETS DB2ConnectionCorrelator: C0A85A03.GABD.140227113853 at com.ibm.db2.jcc.c.a.a(a.java:378) at com.ibm.db2.jcc.c.hb.b(hb.java:191) at com.ibm.db2.jcc.c.hb.c(hb.java:238) at com.ibm.db2.jcc.c.hb.c(hb.java:353) at com.ibm.db2.jcc.c.hb.v(hb.java:1364) at com.ibm.db2.jcc.c.ib.c(ib.java:172) at com.ibm.db2.jcc.c.u.c(u.java:38) at com.ibm.db2.jcc.c.b.pb(b.java:2647) at com.ibm.db2.jcc.a.p.q(p.java:1496) at com.ibm.db2.jcc.a.p.o(p.java:1459) at com.ibm.db2.jcc.c.b.o(b.java:4541) at com.ibm.db2.jcc.a.p.rollback(p.java:1430) at org.hibernate.transaction.JDBCTransaction.rollbackAndResetAutoCommit(JDBCTransaction.java:213) at org.hibernate.transaction.JDBCTransaction.rollback(JDBCTransaction.java:192) at jelettrix.util.Helper.rollbackTransaction(Helper.java:387) at jelettrix.trayapp.ExpCreditBoard.run(ExpCreditBoard.java:120) at java.util.TimerThread.mainLoop(Unknown Source) at java.util.TimerThread.run(Unknown Source) 2014-02-05 21:59:18,386 WARN [Timer-0]: (JDBCExceptionReporter.java:233) JDBCExceptionReporter - SQL Error: -99999, SQLState: 08003 2014-02-05 21:59:18,386 ERROR [Timer-0]: (JDBCExceptionReporter.java:234) JDBCExceptionReporter - invalid operation: connection closed 2014-02-05 21:59:18,386 ERROR [Timer-0]: (Helper.java:305) ExpCreditBoard - Errore nel metodo [jelettrix.trayapp.ExpCreditBoard#run()], dettagli: Cannot open connection org.hibernate.exception.JDBCConnectionException: Cannot open connection at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:99) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:52) at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:449) at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167) at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:160) at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:81) at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1473) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:345) at $Proxy17.beginTransaction(Unknown Source) at jelettrix.trayapp.ExpCreditBoard.run(ExpCreditBoard.java:132) at java.util.TimerThread.mainLoop(Unknown Source) at java.util.TimerThread.run(Unknown Source) Caused by: com.ibm.db2.jcc.a.SqlException: invalid operation: connection closed at com.ibm.db2.jcc.a.p.Hb(p.java:4054) at com.ibm.db2.jcc.a.p.getAutoCommit(p.java:1273) at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:127) at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446) ... 13 more
It looks like the connection fall down while trying to rollback. line 120 is: Helper.rollbackTransaction(session); That execute this code: if (session != null) { if (session.isOpen()) { Transaction trans = session.getTransaction(); if (trans != null) { if (trans.isActive()) { trans.rollback(); } } } }
In this transaction I only read data, without any update or delete so...why rollback gives me error?
Then again it looks like it's impossibile to open again the connection. Later in the code, after try catch block, I have another export to exectue and I try to reopen the connetion but it fails...
Anybody could help me?
Thank you
|