This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Java in General and the fly likes i lost the database connection after 10 hours .. hibernate do cry myself ;..( Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "i lost the database connection after 10 hours .. hibernate do cry myself ;..(" Watch "i lost the database connection after 10 hours .. hibernate do cry myself ;..(" New topic
Author

i lost the database connection after 10 hours .. hibernate do cry myself ;..(

fernando guiXen
Greenhorn

Joined: Nov 29, 2003
Posts: 12
hi people..
first i sorry for my english
i have a small site that i want tu powered by hibernate and all was right.. but at next day i had a problem with the database.. "ouch!" i said.. what happend.. mmm.. well.. i restart the tomcat and all rigth ..
but the next day the same.. the same problem.. and i restart the tomcat .. and all right..
i dont know.. i close all session after i use it

the problem only happen after 10-20 hours...

i always do this:
} finally {
if( session!=null ){
try {
session.close();
} catch (HibernateException e1) {
e1.printStackTrace();
log.error("al cerrar session.");
}
}
}

and this is my hibernate.properties:
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.connection.url=jdbc:mysql://127.0.0.1:3306/javamola
hibernate.connection.username=xx
hibernate.connection.password=xxx
hibernate.connection.pool_size = 20
hibernate.statement_cache.size = 6
hibernate.show_sql = true

i have read forums.. but i only have found a one answer: use a pool connection.. but hibernate use a pool connection inside, don't it?
thanks friends��
d2clon

this is a summary of error logs:

[35836554] WARN (2003-11-28 08:41:06,869) (JDBCExceptionReporter.java:38) Thread-15 - SQL Error: 0, SQLState: 08S01
[35836557] ERROR (2003-11-28 08:41:06,872) (JDBCExceptionReporter.java:46) Thread-15 - Communication link failure: java.io.IOException, underlying cause: Unexpected end of input stream
** BEGIN NESTED EXCEPTION **
java.io.IOException
MESSAGE: Unexpected end of input stream
STACKTRACE:
java.io.IOException: Unexpected end of input stream
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:1405)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1775)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1020)
(...... more STACK)

(more STACK...)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:536)

** END NESTED EXCEPTION **

[35836599] ERROR (2003-11-28 08:41:06,914) (JDBCException.java:37) Thread-15 - Could not synchronize database state with session
java.sql.SQLException: Communication link failure: java.io.IOException, underlying cause: Unexpected end of input stream
** BEGIN NESTED EXCEPTION **
java.io.IOException
MESSAGE: Unexpected end of input stream
STACKTRACE:
java.io.IOException: Unexpected end of input stream
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:1405)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1775)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1020)

...
(..more and more STACK...)
...
[35836708] WARN (2003-11-28 08:41:07,023) (JDBCExceptionReporter.java:38) Thread-15 - SQL Error: 0, SQLState: 08003
[35836712] ERROR (2003-11-28 08:41:07,027) (JDBCExceptionReporter.java:46) Thread-15 - No operations allowed after connection closed.
Connection was closed due to the following exception:
** BEGIN NESTED EXCEPTION **
java.sql.SQLException
MESSAGE: Communication link failure: java.io.IOException, underlying cause: Unexpected end of input stream
** BEGIN NESTED EXCEPTION **
java.io.IOException
MESSAGE: Unexpected end of input stream
STACKTRACE:
java.io.IOException: Unexpected end of input stream
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:1405)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1775)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1020)
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937
i close all session after i use it
Do you close the database connection (in the finally block) after you use it?
fernando guiXen
Greenhorn

Joined: Nov 29, 2003
Posts: 12
do you want say this?:
} finally {
if( session!=null ){
try {
session.connection().close();
session.close();
} catch (Exception e1) {
e1.printStackTrace();
log.error("al cerrar session.");
}
}
} {

oh my god.. yes?
i am going to test now :=)
thx�
fernando guiXen
Greenhorn

Joined: Nov 29, 2003
Posts: 12
didn't run .. :/
if i write this:
session.connection().close();
session.close();
error ... and if i write this:
session.close();
session.connection().close();
error too..

net.sf.hibernate.HibernateException: Session is currently disconnected

i am reading this:
http://forum.hibernate.org/viewtopic.php?t=279&start=0&postdays=0&postorder=asc
you will have news about this ..
thx�
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937

session.connection().close();
session.close();

What kind of error do you get from the above code? Also, you should check if the connection is alive before trying to close it.
fernando guiXen
Greenhorn

Joined: Nov 29, 2003
Posts: 12
the answer is clear for me now..
the problem was that the mySql database closed the connection before the connection pool could do it...
and the solution is to set a connection pool timeOut smaller than the mySql connection timeOut..
this is my new hibernate.properties
hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect
hibernate.connection.driver_class=com.mysql.jdbc.Driver
.....
hibernate.c3p0.max_size=100
hibernate.c3p0.min_size=3
hibernate.c3p0.timeout=900
hibernate.c3p0.max_statements=100

thx...
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: i lost the database connection after 10 hours .. hibernate do cry myself ;..(
 
Similar Threads
Why I get CommunicationsException using Quartz JobStore web application ?
connection reset on MySQL and Resin-3.0.13
Communications link failure in JBOSS
Communications link failure due to underlying exception
Begin Nested Exception