Project

General

Profile

« Previous | Next » 

Revision 9492

Added by Jing Tao almost 9 years ago

Make sure to close the prepared statement on the final statement.

View differences:

src/edu/ucsb/nceas/metacat/ContentTypeProvider.java
446 446
    {
447 447
      try
448 448
      {
449
        pStmt.close();
449
        if(rs != null) {
450
            rs.close();
451
        }
452
        if(pStmt != null) {
453
            pStmt.close();
454
        }
455
        
450 456
      }
451 457
      catch (SQLException ee)
452 458
      {
......
536 542
    {
537 543
      try
538 544
      {
539
        pStmt.close();
545
          if(rs != null) {
546
              rs.close();
547
          }
548
          if(pStmt != null) {
549
              pStmt.close();
550
          }
551
        
540 552
      }
541 553
      catch(SQLException ee)
542 554
      {
src/edu/ucsb/nceas/metacat/DBEntityResolver.java
220 220
    PreparedStatement pstmt = null;
221 221
    DBConnection conn = null;
222 222
    int serialNumber = -1;
223
    ResultSet rs = null;
223 224
    try {
224 225
      //check out DBConnection
225 226
      conn=DBConnectionPool.getDBConnection("DBEntityResolver.getDTDSystemID");
......
232 233
      pstmt.setString(1, doctype);
233 234
      
234 235
      pstmt.execute();
235
      ResultSet rs = pstmt.getResultSet();
236
      rs = pstmt.getResultSet();
236 237
      boolean tableHasRows = rs.next();
237 238
      if (tableHasRows) {
238 239
        systemid = rs.getString(1);
......
241 242
        	systemid = SystemUtil.getContextURL() + systemid;
242 243
        }
243 244
      }
244
      pstmt.close();
245
      //pstmt.close();
245 246
    } catch (SQLException e) {
246 247
      throw new SAXException
247 248
      ("DBEntityResolver.getDTDSystemID - SQL error when getting DTD system ID: " + e.getMessage());
......
253 254
    {
254 255
      try
255 256
      {
256
        pstmt.close();
257
          if(rs != null) {
258
              rs.close();
259
          }
260
          if(pstmt != null) {
261
              pstmt.close();
262
          }
263
        
257 264
      }//try
258 265
      catch (SQLException sqlE)
259 266
      {

Also available in: Unified diff