When you get connection with this line
DriverManager.getConnection("jdbc:apache:commons:dbcp:example");
You are actually getting a connection wrapped in dbcp wrapper. When you call
close, the wrapper method close is called instead of close on actual db
driver. This wrapper releases the connection instead of closing it.Regards, Tahir -----Original Message----- From: Jawed Nazar Ali [mailto:[EMAIL PROTECTED] Sent: Thursday, June 15, 2006 8:01 PM To: [email protected] Subject: DBCP - Why we close connection Hello, try { conn = DriverManager.getConnection("jdbc:apache:commons:dbcp:example"); stmt = conn.createStatement(); rset = stmt.executeQuery(args[1]); int numcols = rset.getMetaData().getColumnCount(); while(rset.next()) { for(int i=1;i<=numcols;i++) { System.out.print("\t" + rset.getString(i)); } System.out.println(""); } } catch(SQLException e) { e.printStackTrace(); } finally { try { rset.close(); } catch(Exception e) { } try { stmt.close(); } catch(Exception e) { } try { conn.close(); } catch(Exception e) { } } Why we close conn at the end, I don't understand this. Any explanation? Regards, Jawed Nazar Ali -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.394 / Virus Database: 268.8.4/364 - Release Date: 6/14/2006 -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.394 / Virus Database: 268.8.4/364 - Release Date: 6/14/2006 --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
