Your best bet is to use a database connection pool. Look into DBCP. You can set the max number of connections and all your apps can share these connections.
As for your issues, it sounds like the JDBC driver is not closing everything when you call connection.close(). There has been some discussion on how this is suppose to operate on this list, but in general everyone reccomends that you close your recordsets and your statements individually, so your resources are cleaned up immediately, not by garbage collection. - Andrew > -----Original Message----- > From: William Wragg [mailto:[EMAIL PROTECTED]] > Sent: Thursday, September 05, 2002 9:42 AM > To: [EMAIL PROTECTED] > Subject: JDBC connection persistence > > > Hi, > > I have developed a webapp which connects to a database and > retrieves data > for display via JDBC. There are only a few pages and each > page opens and > then closes the connection to the database. The problem is that our > database has only a set number of licensed concurrent > connections, and > although the connections have been closed they hang around, > using up the > licensed connections. At what appear to be random times the > old closed > connections get cleared up which frees up some more licensed > connections. > > I have tried writing the database retrieval in both jsp tags > (sql taglibs) > and in pure java and get the same problem. The connections > are definitely > closed as I have checked if the connection is null after I > have closed the > connection. Also the database confirms that there are no external > connections to it. > > I am running Tomcat 4.0.4, java sdk 1.3_02, on Caldera > OpenLinux 3.1.1 > (kernal 2.4.13) and SCO OpenServer 5.0.5a > > Have I missed something about the setup of JDBC connections. Do they > persist by default, until something triggers a cleanup? > > Any help would be greatly appreciated. > > Regards, > > Wm. > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
