Exemplo n.º 1
0
 /**
  * 获取定量数据
  *
  * @return LEDAdSourceSet
  */
 public LEDAdSourceSet getData() {
   int tCount = 0;
   LEDAdSourceSet tLEDAdSourceSet = new LEDAdSourceSet();
   LEDAdSourceSchema tLEDAdSourceSchema = null;
   if (null == mResultSet) {
     CError tError = new CError();
     tError.moduleName = "LEDAdSourceDB";
     tError.functionName = "getData";
     tError.errorMessage = "数据集为空,请先准备数据集!";
     this.mErrors.addOneError(tError);
     return null;
   }
   try {
     tCount = 1;
     tLEDAdSourceSchema = new LEDAdSourceSchema();
     tLEDAdSourceSchema.setSchema(mResultSet, 1);
     tLEDAdSourceSet.add(tLEDAdSourceSchema);
     // 注意mResultSet.next()的作用
     while (tCount++ < SysConst.FETCHCOUNT) {
       if (mResultSet.next()) {
         tLEDAdSourceSchema = new LEDAdSourceSchema();
         tLEDAdSourceSchema.setSchema(mResultSet, 1);
         tLEDAdSourceSet.add(tLEDAdSourceSchema);
       }
     }
   } catch (Exception ex) {
     CError tError = new CError();
     tError.moduleName = "LEDAdSourceDB";
     tError.functionName = "getData";
     tError.errorMessage = ex.toString();
     this.mErrors.addOneError(tError);
     try {
       mResultSet.close();
       mResultSet = null;
     } catch (Exception ex2) {
     }
     try {
       mStatement.close();
       mStatement = null;
     } catch (Exception ex3) {
     }
     if (!mflag) {
       try {
         con.close();
       } catch (Exception et) {
       }
     }
     return null;
   }
   return tLEDAdSourceSet;
 }
Exemplo n.º 2
0
  public LEDAdSourceSet executeQuery(String sql, int nStart, int nCount) {
    Statement stmt = null;
    ResultSet rs = null;
    LEDAdSourceSet aLEDAdSourceSet = new LEDAdSourceSet();

    if (!mflag) {
      con = DBConnPool.getConnection();
    }

    try {
      stmt = con.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);

      rs = stmt.executeQuery(StrTool.GBKToUnicode(sql));
      int i = 0;
      while (rs.next()) {
        i++;

        if (i < nStart) {
          continue;
        }

        if (i >= nStart + nCount) {
          break;
        }

        LEDAdSourceSchema s1 = new LEDAdSourceSchema();
        if (!s1.setSchema(rs, i)) {
          // @@错误处理
          CError tError = new CError();
          tError.moduleName = "LEDAdSourceDB";
          tError.functionName = "executeQuery";
          tError.errorMessage = "sql语句有误,请查看表名及字段名信息!";
          this.mErrors.addOneError(tError);
        }
        aLEDAdSourceSet.add(s1);
      }
      try {
        rs.close();
      } catch (Exception ex) {
      }
      try {
        stmt.close();
      } catch (Exception ex1) {
      }
    } catch (Exception e) {
      // @@错误处理
      CError tError = new CError();
      tError.moduleName = "LEDAdSourceDB";
      tError.functionName = "executeQuery";
      tError.errorMessage = e.toString();
      this.mErrors.addOneError(tError);

      try {
        rs.close();
      } catch (Exception ex2) {
      }
      try {
        stmt.close();
      } catch (Exception ex3) {
      }

      if (!mflag) {
        try {
          con.close();
        } catch (Exception et) {
        }
      }
    }

    if (!mflag) {
      try {
        con.close();
      } catch (Exception e) {
      }
    }

    return aLEDAdSourceSet;
  }
Exemplo n.º 3
0
  public LEDAdSourceSet query(int nStart, int nCount) {
    Statement stmt = null;
    ResultSet rs = null;
    LEDAdSourceSet aLEDAdSourceSet = new LEDAdSourceSet();

    if (!mflag) {
      con = DBConnPool.getConnection();
    }

    try {
      stmt = con.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
      SQLString sqlObj = new SQLString("LEDAdSource");
      LEDAdSourceSchema aSchema = this.getSchema();
      sqlObj.setSQL(5, aSchema);
      String sql = sqlObj.getSQL();

      rs = stmt.executeQuery(sql);
      int i = 0;
      while (rs.next()) {
        i++;

        if (i < nStart) {
          continue;
        }

        if (i >= nStart + nCount) {
          break;
        }

        LEDAdSourceSchema s1 = new LEDAdSourceSchema();
        s1.setSchema(rs, i);
        aLEDAdSourceSet.add(s1);
      }
      try {
        rs.close();
      } catch (Exception ex) {
      }
      try {
        stmt.close();
      } catch (Exception ex1) {
      }
    } catch (Exception e) {
      // @@错误处理
      CError tError = new CError();
      tError.moduleName = "LEDAdSourceDB";
      tError.functionName = "query";
      tError.errorMessage = e.toString();
      this.mErrors.addOneError(tError);

      try {
        rs.close();
      } catch (Exception ex2) {
      }
      try {
        stmt.close();
      } catch (Exception ex3) {
      }

      if (!mflag) {
        try {
          con.close();
        } catch (Exception et) {
        }
      }
    }

    if (!mflag) {
      try {
        con.close();
      } catch (Exception e) {
      }
    }

    return aLEDAdSourceSet;
  }