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

done.
This commit is contained in:
Redhuan D. Oon 2008-02-04 18:09:23 +00:00
parent f709cb5203
commit f8d99975df
1 changed files with 7 additions and 11 deletions

View File

@ -66,11 +66,12 @@ public class MClient extends X_AD_Client
{ {
ArrayList<MClient> list = new ArrayList<MClient>(); ArrayList<MClient> list = new ArrayList<MClient>();
String sql = "SELECT * FROM AD_Client"; String sql = "SELECT * FROM AD_Client";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql, null); pstmt = DB.prepareStatement (sql, null);
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
{ {
MClient client = new MClient (ctx, rs, null); MClient client = new MClient (ctx, rs, null);
@ -85,15 +86,10 @@ public class MClient extends X_AD_Client
{ {
s_log.log(Level.SEVERE, sql, e); s_log.log(Level.SEVERE, sql, e);
} }
try finally
{ {
if (pstmt != null) DB.close(rs, pstmt);
pstmt.close (); rs = null; pstmt = null;
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
} }
MClient[] retValue = new MClient[list.size ()]; MClient[] retValue = new MClient[list.size ()];
list.toArray (retValue); list.toArray (retValue);