*BF [ 1874419 ] JDBC Statement not close in a finally block

This commit is contained in:
Redhuan D. Oon 2008-02-19 13:35:38 +00:00
parent b352e3960b
commit 78f067a5b6
1 changed files with 6 additions and 11 deletions

View File

@ -21,7 +21,7 @@ package org.adempiere.util;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.logging.*; import java.util.logging.Level;
import org.compiere.Adempiere; import org.compiere.Adempiere;
import org.compiere.util.CLogMgt; import org.compiere.util.CLogMgt;
@ -125,19 +125,17 @@ public class GenerateModel
// //
int count = 0; int count = 0;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement(sql.toString(), null); pstmt = DB.prepareStatement(sql.toString(), null);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
new ModelInterfaceGenerator(rs.getInt(1), directory, packageName); new ModelInterfaceGenerator(rs.getInt(1), directory, packageName);
new ModelClassGenerator(rs.getInt(1), directory, packageName); new ModelClassGenerator(rs.getInt(1), directory, packageName);
count++; count++;
} }
rs.close();
pstmt.close();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
@ -145,11 +143,8 @@ public class GenerateModel
} }
finally finally
{ {
try { DB.close(rs, pstmt);
if (pstmt != null) rs = null; pstmt = null;
pstmt.close ();
} catch (Exception e) { /* ignored */ }
pstmt = null;
} }
log.info("Generated = " + count); log.info("Generated = " + count);
} }