Return-Path: Delivered-To: apmail-jakarta-struts-dev-archive@jakarta.apache.org Received: (qmail 20913 invoked by uid 500); 22 May 2001 11:42:31 -0000 Mailing-List: contact struts-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk Reply-To: struts-dev@jakarta.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list struts-dev@jakarta.apache.org Received: (qmail 20856 invoked from network); 22 May 2001 11:42:24 -0000 Received: from smtp016.mail.yahoo.com (216.136.174.113) by h31.sny.collab.net with SMTP; 22 May 2001 11:42:24 -0000 Received: from cpe-61-9-171-154.vic.bigpond.net.au (HELO dragon) (61.9.171.154) by smtp.mail.vip.sc5.yahoo.com with SMTP; 22 May 2001 11:42:23 -0000 X-Apparently-From: Message-ID: <000201c0e2b4$23971b30$9aab093d@dragon> From: "Hudson Wong" To: References: <00db01c0dfb5$0afb7460$4c01a8c0@int.itechnology.de> Subject: Re: JDBC Connection Pooling Date: Tue, 22 May 2001 21:29:54 +1000 MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2462.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2462.0000 X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N For a connection pool, con.close() puts the connection back into the pool instead of really closing the connection. Thus, you must explicitly close the statements. ----- Original Message ----- From: "Gregor Rayman" To: Sent: Saturday, May 19, 2001 2:10 AM Subject: JDBC Connection Pooling > Hi, I've just found one subtle problem the Struts implementation > of DataSource. > > My code looks something like this: > > ... > Connection con = this.dataSource.getConnection(); > try { > PreparedStatement stmt = con.prepareStatement(sql); > stmt.setString(1, id); > ResultSet rs = stmt.executeQuery(); > String result = null; > if (rs.next()) { > result = rs.getString(1); > } > return result; > } finally { > con.close(); > } > ... > > Obviously, there is an error. I do not close either the ResultSet > nor the Statement. But I do close the Connection, so that the > connection is returned to the DataSource's pool. > > I realized my error, because Oracle complained about too many > open cursors after a while. > > Shouldn't the call to con.close() close all open statements or at > least warn about open ones? > > -- > gR _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com