ColdMillenium / jwpl

Automatically exported from code.google.com/p/jwpl
0 stars 0 forks source link

Hibernate and MySql short timeout #84

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Connecting to database with new Wikipedia object.
2. Waiting for 10 seconds after connection or after query.
3. Querying database  

What is the expected output? What do you see instead?
I expect the query result, instead I have a "Communication link failure". If I 
try to make another query, I have "nested transactions not supported".
I can't change database timeout. Is it possible to modify hibernate properties 
to avoid the problem?

What version of the product are you using? On what operating system?
JWPL 0.9.1 on Windows XP

Please provide any additional information below.

WARN [prefuse_ActivityManager] (SqlExceptionHelper.java:143) - SQL Error: 0, 
SQLState: 08S01
ERROR [prefuse_ActivityManager] (SqlExceptionHelper.java:144) - Communications 
link failure

The last packet successfully received from the server was 304.015 milliseconds 
ago.  The last packet sent successfully to the server was 15 milliseconds ago.
org.hibernate.TransactionException: nested transactions not supported

Original issue reported on code.google.com by cppgabri...@gmail.com on 30 Mar 2012 at 2:50

GoogleCodeExporter commented 9 years ago
What is your query? Does this happen with all API calls?
It seems like one of the API calls opens a transaction without closing it.
The next API call then causes a nested transaction exception when opening a new 
transaction.
So, please provide information which API call it was that caused this problem 
and whether other API calls also cause this exception.

Also: Which MySQL Server version did you use?

Original comment by oliver.ferschke on 12 Apr 2012 at 7:06

GoogleCodeExporter commented 9 years ago
mysql version = 5.1.49-3

The following steps simulate the problem:

    Wikipedia wiki = new Wikipedia(dbConfig);
    Category topC = wiki.getCategory(CATEGORY);
    //The above query runs perfectly
    Thread.sleep(20000);
    topC = wiki.getCategory(CATEGORY);
    //Console Output is in "firstError.txt"

If I try to catch the jdbc exception, redoing the same query (getCategory), I 
have the "nested transaction" problem.
I have also tried to close the current session and the SessionBuilder but the 
problem persists.

I think all queries have the same behavior.

Thanks for any help

Original comment by cppgabri...@gmail.com on 13 Apr 2012 at 2:44

Attachments:

GoogleCodeExporter commented 9 years ago
I could not reproduce this behavior.
Your code example works fine on my machine.

Original comment by oliver.ferschke on 13 Apr 2012 at 4:55

GoogleCodeExporter commented 9 years ago
Please, try to reproduce the behavior with this mysql configuration.

Original comment by cppgabri...@gmail.com on 23 Apr 2012 at 4:54

Attachments:

GoogleCodeExporter commented 9 years ago
If JWPL can be configured with a c3p0 connection pool, that should resolve the 
problem. The pool will automatically create/reopen connections as necessary.

Original comment by richard.eckart on 24 Apr 2012 at 10:47

GoogleCodeExporter commented 9 years ago
Problem solved!!!! I have run the application with -Dhibernate.c3p0.timeout=10. 
Thanks

Original comment by cppgabri...@gmail.com on 24 Apr 2012 at 1:14

GoogleCodeExporter commented 9 years ago
Hi, great that the issue is solved.
I thought I already switched to the c3p0 connection pool, but this was actually 
in another project. 

Original comment by oliver.ferschke on 25 Apr 2012 at 9:34

GoogleCodeExporter commented 9 years ago
I have a similar problem, could you please describe your solution in detail 
(how to configure the c3p0)?
Thanks.

Original comment by astronau...@gmail.com on 26 Apr 2012 at 8:34

GoogleCodeExporter commented 9 years ago
I have never configured c3p0. Simply add c3p0-0.9.1.jar and 
hibernate-c3p0-4.1.1.Final.jar in your build path, then run your application 
with the option 
-Dhibernate.c3p0.timeout=[your timeout]

This option overrides the default configuration.
If you don't want to use it by command line, you can add the following line in 
your code:
System.setProperty("hibernate.c3p0.timeout", "10"); //10 is the chosen timeout

I hope this works for you.

Original comment by cppgabri...@gmail.com on 26 Apr 2012 at 9:00

GoogleCodeExporter commented 9 years ago
It works for me.
Thank you

Original comment by astronau...@gmail.com on 26 Apr 2012 at 1:46

GoogleCodeExporter commented 9 years ago
Fixed in r573/574
c3p0 connection pool is now configured and dependency added

Original comment by oliver.ferschke on 3 May 2012 at 8:05

GoogleCodeExporter commented 9 years ago

Original comment by oliver.ferschke on 15 Aug 2012 at 9:21