[ 1874419 ] JDBC Statement not close in a finally block
This commit is contained in:
parent
1867cee0a3
commit
b1627547d0
|
@ -87,9 +87,10 @@ public class DataEngine
|
||||||
+ "FROM AD_Table t"
|
+ "FROM AD_Table t"
|
||||||
+ " INNER JOIN AD_ReportView rv ON (t.AD_Table_ID=rv.AD_Table_ID) "
|
+ " INNER JOIN AD_ReportView rv ON (t.AD_Table_ID=rv.AD_Table_ID) "
|
||||||
+ "WHERE rv.AD_ReportView_ID=?"; // 1
|
+ "WHERE rv.AD_ReportView_ID=?"; // 1
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
pstmt = DB.prepareStatement(sql, null);
|
||||||
pstmt.setInt(1, format.getAD_ReportView_ID());
|
pstmt.setInt(1, format.getAD_ReportView_ID());
|
||||||
ResultSet rs = pstmt.executeQuery();
|
ResultSet rs = pstmt.executeQuery();
|
||||||
if (rs.next())
|
if (rs.next())
|
||||||
|
@ -101,33 +102,40 @@ public class DataEngine
|
||||||
if (!Util.isEmpty(whereClause))
|
if (!Util.isEmpty(whereClause))
|
||||||
query.addRestriction(whereClause);
|
query.addRestriction(whereClause);
|
||||||
}
|
}
|
||||||
rs.close();
|
rs.close();
|
||||||
pstmt.close();
|
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, sql, e);
|
log.log(Level.SEVERE, sql, e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
DB.close(pstmt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
String sql = "SELECT TableName FROM AD_Table WHERE AD_Table_ID=?"; // #1
|
String sql = "SELECT TableName FROM AD_Table WHERE AD_Table_ID=?"; // #1
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
|
pstmt = DB.prepareStatement(sql.toString(), null);
|
||||||
pstmt.setInt(1, format.getAD_Table_ID());
|
pstmt.setInt(1, format.getAD_Table_ID());
|
||||||
ResultSet rs = pstmt.executeQuery();
|
ResultSet rs = pstmt.executeQuery();
|
||||||
if (rs.next())
|
if (rs.next())
|
||||||
tableName = rs.getString(1); // TableName
|
tableName = rs.getString(1); // TableName
|
||||||
rs.close();
|
rs.close();
|
||||||
pstmt.close();
|
|
||||||
}
|
}
|
||||||
catch (SQLException e1)
|
catch (SQLException e1)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, sql, e1);
|
log.log(Level.SEVERE, sql, e1);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
DB.close(pstmt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (tableName == null)
|
if (tableName == null)
|
||||||
{
|
{
|
||||||
|
@ -659,9 +667,10 @@ public class DataEngine
|
||||||
+ " INNER JOIN AD_Column cd ON (rt.AD_Display = cd.AD_Column_ID) "
|
+ " INNER JOIN AD_Column cd ON (rt.AD_Display = cd.AD_Column_ID) "
|
||||||
+ "WHERE rt.AD_Reference_ID=?" // 1
|
+ "WHERE rt.AD_Reference_ID=?" // 1
|
||||||
+ " AND rt.IsActive = 'Y' AND t.IsActive = 'Y'";
|
+ " AND rt.IsActive = 'Y' AND t.IsActive = 'Y'";
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PreparedStatement pstmt = DB.prepareStatement(SQL, null);
|
pstmt = DB.prepareStatement(SQL, null);
|
||||||
pstmt.setInt (1, AD_Reference_Value_ID);
|
pstmt.setInt (1, AD_Reference_Value_ID);
|
||||||
ResultSet rs = pstmt.executeQuery();
|
ResultSet rs = pstmt.executeQuery();
|
||||||
if (rs.next())
|
if (rs.next())
|
||||||
|
@ -673,12 +682,15 @@ public class DataEngine
|
||||||
tr.IsTranslated = "Y".equals(rs.getString(5));
|
tr.IsTranslated = "Y".equals(rs.getString(5));
|
||||||
}
|
}
|
||||||
rs.close();
|
rs.close();
|
||||||
pstmt.close();
|
|
||||||
}
|
}
|
||||||
catch (SQLException ex)
|
catch (SQLException ex)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, SQL, ex);
|
log.log(Level.SEVERE, SQL, ex);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
DB.close(pstmt);
|
||||||
|
}
|
||||||
return tr;
|
return tr;
|
||||||
} // getTableReference
|
} // getTableReference
|
||||||
|
|
||||||
|
@ -698,9 +710,10 @@ public class DataEngine
|
||||||
boolean hasLevelNo = pd.hasLevelNo();
|
boolean hasLevelNo = pd.hasLevelNo();
|
||||||
int levelNo = 0;
|
int levelNo = 0;
|
||||||
//
|
//
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PreparedStatement pstmt = DB.prepareStatement(pd.getSQL(), null);
|
pstmt = DB.prepareStatement(pd.getSQL(), null);
|
||||||
ResultSet rs = pstmt.executeQuery();
|
ResultSet rs = pstmt.executeQuery();
|
||||||
// Row Loop
|
// Row Loop
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
|
@ -888,12 +901,15 @@ public class DataEngine
|
||||||
|
|
||||||
} // for all rows
|
} // for all rows
|
||||||
rs.close();
|
rs.close();
|
||||||
pstmt.close();
|
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, pdc + " - " + e.getMessage() + "\nSQL=" + pd.getSQL());
|
log.log(Level.SEVERE, pdc + " - " + e.getMessage() + "\nSQL=" + pd.getSQL());
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
DB.close(pstmt);
|
||||||
|
}
|
||||||
|
|
||||||
// -- we have all rows - finish
|
// -- we have all rows - finish
|
||||||
// Check last Group Change
|
// Check last Group Change
|
||||||
|
|
Loading…
Reference in New Issue