| Author |
Connection timeout issues
|
Sasikanth Malladi
Ranch Hand
Joined: Nov 04, 2000
Posts: 175
|
|
All, I have an application that connects to a DB via JDBC. In the init() method of my app, I'm initializing the connection to the DB. When the client makes a request, the connection will be used to run a query and get the results. My problem is this: mine is a long running server process. It could sometimes be days or hours between requests and the DB connection is closed. How do I keep this connection alive indefinitely? What are the typical approaches in this case? Would connection pooling be a good idea? Thanks for any pointers, Sashi
|
 |
Stan James
(instanceof Sidekick)
Ranch Hand
Joined: Jan 29, 2003
Posts: 8791
|
|
Before doing anything tricky, I'd ask how important it is. What bad things happen if you connect, query, disconnect every time you access the database? If you're about to say it's slow, have you measured how slow? What good things happen if you connect every time? If the database stops and restarts, no problem. If a momentary network outage kills one attempt, the next one will still work fine.
|
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
|
 |
Sasikanth Malladi
Ranch Hand
Joined: Nov 04, 2000
Posts: 175
|
|
Good answer, Stan. I've been brainwashed into thinking about "expensive" connections and I automatically avoided that route without experimenting. It turns out that the time times is less than 100 ms for a connection. For my application, that is perhaps within allowable limits. Regards, Sashi
|
 |
 |
|
|
subject: Connection timeout issues
|
|
|