Connecting to database logic

I need help to define the best approach to avoid connection jam.

I am writing some classes that read xml file, save to local disk, parse its contents, send receiving notification & insert the contents in oracle database. The xml file is sent over a network and I have a listener (servlet). Once the file is received, the process explained at the beginning starts. I open a new connection database, do whatever I want then close it. I am trying to think of another way so that I open the connection for certain time and then close it when it is not used after say 3 minutes. Is there any way to apply the logic or a better logic?

Highly appreciated,

[671 byte] By [hfs1981a] at [2007-9-29 4:27:15]
# 1

You can create a Singleton object that pools a number of active

connections to the database. Your servlets would then connect to the

pool and obtain a connection, use it then return it to the pool. The

pool would handle creating and destroying the connections based on

whatever policy best suits you.

see

http://forum.java.sun.com/thread.jsp?forum=426&thread=418473&tstart=0&trange=30

for an example of object pooling

matfud

matfuda at 2007-7-14 17:48:35 > top of Java-index,Other Topics,Algorithms...