From: SVN by r. <sv...@ca...> - 2009-12-16 11:32:59
|
Author: roy Date: 2009-12-16 12:32:47 +0100 (Wed, 16 Dec 2009) New Revision: 439 Modified: src/main/java/nl/improved/sqlclient/commands/DumpCommand.java Log: close statements and resultsets Modified: src/main/java/nl/improved/sqlclient/commands/DumpCommand.java =================================================================== --- src/main/java/nl/improved/sqlclient/commands/DumpCommand.java 2009-12-16 10:12:50 UTC (rev 438) +++ src/main/java/nl/improved/sqlclient/commands/DumpCommand.java 2009-12-16 11:32:47 UTC (rev 439) @@ -83,6 +83,8 @@ String query = "select * from " + result[2]; int rowCount = 0; PrintWriter out = null; + Statement stmt = null; + ResultSet rs = null; try { File f; if (dumpFileName.toLowerCase().endsWith(".dmp")) { @@ -109,8 +111,8 @@ // USERS tag. hd.startElement("", "", "dump", atts); Connection c = DBConnector.getInstance().getConnection(); - Statement stmt = c.createStatement(); - ResultSet rs = stmt.executeQuery(query); + stmt = c.createStatement(); + rs = stmt.executeQuery(query); SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT); while (rs.next()) { atts.clear(); @@ -180,6 +182,12 @@ } catch (IOException e) { throw new IllegalStateException("Failed to create dump (" + fileName + "): " + e.toString(), e); } finally { + if (rs != null) { + try { rs.close(); } catch(Exception e) { /* ignore */} + } + if (stmt != null) { + try { stmt.close(); } catch(Exception e) { /* ignore */} + } if (out != null) { out.close(); } |