Пример #1
0
  /** Execute the query and get the results. */
  public void load(int startRow, int length) throws KExceptionClass {
    bindDBtransaction(
        dbTransactionClient,
        " SELECT " + selectSQL + " FROM " + tableName + finalWhere + finalOrder);

    // Query DB
    try {

      KMetaUtilsClass.cursorWait(parentWindow);
      KMetaUtilsClass.setProgressBarValue1(60);

      dbTransactionClient.executeQuery(startRow, length);

      KMetaUtilsClass.setProgressBarValue1(100);

    } finally {
      KMetaUtilsClass.cursorNormal(parentWindow);
    }

    if (!dbTransactionClient.columnNamesList.contains(keyField)) {
      throw new KExceptionClass(
          "*** Could not load data **** \n"
              + "Key field ["
              + keyField
              + "] was not found in result set",
          null);
    }

    firstLoadReady = true;

    log.log(this, "dbTransactionClient rowCount = " + dbTransactionClient.rowCount());
    log.log(this, "dbTransactionClient startRow = " + dbTransactionClient.resultSetStart());
  }
Пример #2
0
  /** make SQL query for certain operation and return the result. */
  public Map executeSQLOperation(String operation, boolean reflectCustomFilter)
      throws KExceptionClass {

    dbTransactionClientClass dbTransaction = new dbTransactionClientClass(configuration, log);
    String sql;

    if (reflectCustomFilter) {
      // do bind custom parameters
      sql = " SELECT " + operation + " FROM " + tableName + finalWhere;
      bindDBtransaction(dbTransaction, sql);

    } else {
      // do NOT bind custom parameters
      sql = " SELECT " + operation + " FROM " + tableName + defaultWhere;
      bindDefaultDBtransaction(dbTransaction, sql);
    }
    ;

    // Query to DB
    dbTransaction.executeQuery(0, 10);

    if (!dbTransaction.fetch())
      throw new KExceptionClass(
          "*** SQL total error **** \n" + "No row was returned." + "SQL: [" + sql + "]\n ", null);

    return (dbTransaction);
  }
Пример #3
0
  /** prepare DB transaction */
  private void bindDBtransaction(dbTransactionClientClass dbTransaction, String sql)
      throws KExceptionClass {
    dbTransaction.reset();

    // Prepares the SQL string
    dbTransaction.prepare(sql);

    // binding main parameters
    Iterator parameters = mainBindingParameterList.iterator();
    while (parameters.hasNext()) {
      // save sql parameters
      boundParameterClass currentBoundParameter = (boundParameterClass) parameters.next();
      dbTransaction.dynamicBind(
          currentBoundParameter.parameterIndex, currentBoundParameter.parameterValue);
    }

    // binding sub parameters
    parameters = customBindingParameterList.iterator();
    while (parameters.hasNext()) {
      // save sql parameters
      boundParameterClass currentBoundParameter = (boundParameterClass) parameters.next();
      dbTransaction.dynamicBind(
          currentBoundParameter.parameterIndex, currentBoundParameter.parameterValue);
    }
  }
Пример #4
0
  /** get number of rows being loaded */
  public int getloadedRowCount() throws KExceptionClass {
    if (!firstLoadReady)
      throw new KExceptionClass(
          "*** Data Loading error **** \n" + "Can not return row count before data loading...",
          null);

    return dbTransactionClient.rowCount();
  }
Пример #5
0
  /** get first loaded row index in DB table */
  public int getloadedStartRowIndex() throws KExceptionClass {
    if (!firstLoadReady)
      throw new KExceptionClass(
          "*** Data Loading error **** \n" + "Can not return start row before data loading...",
          null);

    return dbTransactionClient.resultSetStart();
  }
Пример #6
0
  /** get next loaded value */
  public void getRowValue(recordClass record) throws KExceptionClass {
    if (record == null)
      throw new KExceptionClass(
          "*** Object reference error **** \n" + "The reference is null.", null);

    int fieldIndex = 0;
    Iterator columnNames = dbTransactionClient.columnNamesList.iterator();

    // build current row
    while (columnNames.hasNext()) {

      String column_name = (String) columnNames.next();

      // Add the key value to the last record field
      if (column_name.equals(keyField))
        record.setValueAt(
            record.getRecordLength() - 1, dbTransactionClient.getProperty(column_name));

      if (showKeyField || !column_name.equals(keyField)) {
        record.setValueAt(fieldIndex++, dbTransactionClient.getProperty(column_name));
      }
    }
  }
Пример #7
0
 /** check whether therer is any loaded value */
 public boolean nextRowValue() throws KExceptionClass {
   return dbTransactionClient.fetch();
 }
Пример #8
0
  public boolean isFieldNumeric(int columnIndex) throws KExceptionClass {

    return (dbTransactionClient.isColumnNumeric(columnIndex));
  }
Пример #9
0
  /** get related dbfield name via displayFieldName name */
  public int getFieldType2(int columnIndex) throws KExceptionClass {

    return (dbTransactionClient.getColumnType(columnIndex));
  }