Example #1
0
  public int updateTqcBatch(String statment, Object obj)
      throws DataAccessIntegrityViolationException, DataAccessException {

    SqlMapClient sqlmapclient = this.getSqlMapClient();
    int o = 0;
    List<TqcAlarm> list = null;
    try {
      if (null == obj) {
        throw new DataAccessException("the obj value is null");
      }
      if (!(obj instanceof List)) {
        throw new UnsupportedOperationException("the obj should be List instance");
      } else {
        list = (List<TqcAlarm>) obj;
      }
      // 开启批处理
      sqlmapclient.startBatch();
      for (TqcAlarm alarm : list) {
        o = getSqlMapClientTemplate().update(statment, alarm);
      }
      // 批处理执行
      sqlmapclient.executeBatch();
      return o;
    } catch (SQLException e) {
      throw new DataAccessException(e);
    } catch (Exception e) {
      throw new DataAccessException(e);
    }
  }
Example #2
0
  public boolean insertRankingHistory(UserDTO dto) throws Exception {
    boolean result = false;

    try {
      sqlClient.startTransaction();
      sqlClient.startBatch();

      sqlClient.insert("UserInfo.insertRankingHistory", dto);

      sqlClient.executeBatch();
      sqlClient.commitTransaction();

      result = true;
    } catch (Exception e) {
      logger.error("sql Exception : " + e.getMessage());
      throw new Exception("TwitterRankDAO.insertRankingHistory:" + e.getMessage());
    } finally {
      sqlClient.endTransaction();
    }

    return result;
  }
Example #3
0
 public boolean insertUserList(List<UserDTO> list) throws Exception {
   boolean result = false;
   try {
     // 트랜잭션 시작
     sqlClient.startTransaction();
     // 배치작업 준비 시작
     sqlClient.startBatch();
     for (UserDTO dto : list) {
       sqlClient.insert("UserInfo.insertUserList", dto);
     }
     // 배치작업 실행.
     sqlClient.executeBatch();
     // 정상 완료 후 커밋
     sqlClient.commitTransaction();
     result = true;
   } catch (Exception e) {
     logger.error("sql Exception : " + e.getMessage());
     throw new Exception("TwitterRankDAO.getUserList:" + e.getMessage());
   } finally { // 문제 발생시 트랜잭션 종료(작업 적용안함)
     sqlClient.endTransaction();
   }
   return result;
 }