コード例 #1
0
  // return the records count number according sql
  public long getRecordsCountFromSql(String sql) throws FrameworkDAOException {
    // Initialize values
    ResultSet ret = null;
    Statement stmt = null;
    Connection connection = null;
    int count = 0;

    try {
      // String sSQL = sql;
      connection = ((DatabaseQuerier) getConnection()).getSafeConnection();
      stmt = connection.createStatement();
      ret = stmt.executeQuery(sql);
      while (ret.next()) {
        count++;
      }
    } catch (Exception exc) {
      throw new FrameworkDAOException(
          "S_Framework_Entry_UIDAO:getRecordsCountFromSql - " + exc, exc);
    } finally {
      String errorMsg = "Inside S_Framework_Entry_UIDAO:getRecordsCountFromSql()";
      try {
        if (ret != null) {
          ret.close();
          ret = null;
        }
      } catch (Exception e) {
        FrameworkDefaultLogger.error(errorMsg + " - 关闭时出错!\n" + e);
      }
      try {
        if (stmt != null) {
          stmt.close();
          stmt = null;
        }
      } catch (Exception e) {
        FrameworkDefaultLogger.error(errorMsg + " - 关闭时出错!\n" + e);
      }
      try {
        if (connection != null) {
          connection.close();
          connection = null;
        }
      } catch (Exception e) {
        FrameworkDefaultLogger.error(errorMsg + " - 关闭时出错!\n" + e);
      }
    }
    return count;
  }
コード例 #2
0
 /**
  * @return
  * @throws FrameworkDAOException
  */
 public long getMaxOIDForS_Framework_Entry_UIValueObjects() throws FrameworkDAOException {
   // Initialize values
   ResultSet ret = null;
   Statement stmt = null;
   Connection connection = null;
   long count = 0;
   String sGetMaxOIDSql = "select max(testid) from test";
   try {
     connection = ((DatabaseQuerier) getConnection()).getSafeConnection();
     stmt = connection.createStatement();
     ret = stmt.executeQuery(sGetMaxOIDSql);
     while (ret.next()) {
       count = ret.getLong(1);
     }
   } catch (Exception exc) {
     throw new FrameworkDAOException(
         "S_Framework_Entry_UIDAO:getMaxOIDForS_Framework_Entry_UIValueObjects - " + exc, exc);
   } finally {
     String errorMsg =
         "Inside S_Framework_Entry_UIDAO:getMaxOIDForS_Framework_Entry_UIValueObjects()";
     try {
       if (ret != null) {
         ret.close();
         ret = null;
       }
     } catch (Exception e) {
       FrameworkDefaultLogger.error(errorMsg + " - 关闭时出错!\n" + e);
     }
     try {
       if (stmt != null) {
         stmt.close();
         stmt = null;
       }
     } catch (Exception e) {
       FrameworkDefaultLogger.error(errorMsg + " - 关闭时出错!\n" + e);
     }
     try {
       if (connection != null) {
         connection.close();
         connection = null;
       }
     } catch (Exception e) {
       FrameworkDefaultLogger.error(errorMsg + " - 关闭时出错!\n" + e);
     }
   }
   return count;
 }