[ 1874419 ] JDBC Statement not close in a finally block

This commit is contained in:
Heng Sin Low 2008-02-05 08:34:52 +00:00
parent 1873121a4e
commit 7891512128
1 changed files with 16 additions and 28 deletions

View File

@ -1034,12 +1034,13 @@ public class MSequence extends X_AD_Sequence
int counter = 0;
boolean success = true;
//
PreparedStatement pstmt = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, trxName);
pstmt.setInt(1, AD_Client_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
String tableName = rs.getString(1);
@ -1054,23 +1055,16 @@ public class MSequence extends X_AD_Sequence
success = false;
}
}
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
s_log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
s_log.info ("AD_Client_ID=" + AD_Client_ID
+ " - created #" + counter
@ -1121,33 +1115,27 @@ public class MSequence extends X_AD_Sequence
+ "WHERE UPPER(Name)=?"
+ " AND IsTableID='Y'";
MSequence retValue = null;
PreparedStatement pstmt = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, trxName);
pstmt.setString (1, tableName.toUpperCase());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
if (rs.next ())
retValue = new MSequence (ctx, rs, trxName);
if (rs.next())
s_log.log(Level.SEVERE, "More then one sequence for " + tableName);
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log(Level.SEVERE, "get", e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return retValue;
} // get