• Post Reply Bookmark Topic Watch Topic
  • New Topic

MySQL 4.1 + Tomcat 5.5 + CVS version: Connection reset  RSS feed

 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!