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