Forums Register Login

db connection timeout

+Pie Number of slices to send: Send
I am having a problem with a connection object timing out in a servlet. The connection is created in a servlets init() method and is used indefinitely in synchonized methods throughout the servlet while the web application runs. This worked ok with microsoft sql, but now using mySql the connection times out and then creates SQLExceptions.
Does anyone know how best to fix this? Should I catch each sql exception and test for the connection being null and if it is create a new one? (Seems a bit long-winded). Or is there a Better Way?
Many thanks
+Pie Number of slices to send: Send
Use a connection pool. The simplest approach is to persuade your application server to make a DataSource available that you look up using JNDI. Otherwise, look into the Apache Jakarta Commons DBCP (DataBase Connection Pool).
- Peter
I am not a spy. Definitely. Definitely not a spy. Not me. No way. But this tiny ad ...
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1229 times.
Similar Threads
Connection Problem
Connect to db, simple question !!
How can I fix this REALLY URGENT
jsp odbc problems
maintaining a connection
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 19:02:02.