• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

MySQL 4.1 + Tomcat 5.5 + CVS version: Connection reset

 
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I run the CVS version on tomcat 5.5 and Mysql 4.1, the datasource loses it's connection every night and doesn't recover from it. Each morning I have to restart the tomcat server.
After a quick look in the code I have fixed the problem with following pieces of code in de C3P0PooledConnection:



Now I'm going to test the connection before returning it to the application. If it fails, I'm refreshing the entire connection pool.

[Edit[Sorry, this is in the wrong subforum, can you move it to the correct one. Thanks[/Edit]
[originally posted on jforum.net by mortis__rigor]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You don't need this code hack. C3P0 already have these configuration options for you.
Open the file WEB-INF/classes/c3p0.properties and add this:



This will test the connection every time.

Also, please note that this is mysql's behaviour, that, by default, kills all connections that were inactive for 8 hours.
For that, add he following option to c3p0.properties:



Note that, if you use this option, you don't need the first two

Rafael
[originally posted on jforum.net by Rafael Steil]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, thank you. I will check it out.
[originally posted on jforum.net by mortis__rigor]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm sorry too that those sollutions didn't fixed the problem.
However, I did some code reading and did find the solution. I added the following parameter to the configuration file:
database.ping.delay=<time in seconds>
[originally posted on jforum.net by mortis__rigor]
 
He's my best friend. Not yours. Mine. You can have this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic