Well, if you do implement/use a connection pool, you probably
don't want to close() each Connection after you use it - you want to return it to the pool, so it can be re-used. Many connection pool implementations solve this problem by overriding close() in the Connection so that merely returns the object to the pool, without "really" closing it. So in this case you
do close() the connection, but you don't
really close it. Very
. Anyway, the point is, if you use a connection pool, make sure you know whether you're supposed to close() or not, and act accordingly.
Back to Neelima's question though - Robert's right, the problem is most likely that there are too many open connections/statements/resultsets. Assuming you're not currently using a connection pool - first, make sure you are in fact closing each connection when you're done with it (
if you're really done with it). And close each Statement when you're done. And each ResultSet. Commonly you may find you can reuse the same Connection for many Statements, and/or use the same Statement for many different ResultSets - so close each as soon as you're really done with it, but not if you're going to reuse it. Garbage collection may take care of this for you, but don't count on it - use finally {} as Robert suggests. See if this solves your problem. Then if you still have a problem, or if you want to improve overall performance, look into setting up a connection pool.
[ February 13, 2003: Message edited by: Jim Yingst ]