Package com.lingbobu.flashdb.common

Examples of com.lingbobu.flashdb.common.QueryResultSet


      if (i > 0) ts.append(',');
      ts.append('?');
    }
    ts.append(')');
   
    QueryResultSet qrs = flashDatabase.executeQuery(ts.toString(), params);
    return new JdbcResultSet(qrs);
  }
View Full Code Here


 
  Object execute(String sql, Object[] params, int maxRows) {
    Object ret = flashDatabase.execute(sql, params, maxRows);
   
    if ((ret != null) && (ret instanceof QueryResultSet)) {
      QueryResultSet qrs = (QueryResultSet) ret;
      ResultSetNextPart rsContinue = null;
      if ((maxRows < 0) && qrs.isResultHasContinueData()) {
        rsContinue = new ResultSetNextPart(flashDatabase, sql, params, -maxRows);
      }
      return new JdbcResultSet((QueryResultSet)ret, rsContinue);
    }
    return ret;
View Full Code Here

    flashDatabase.executeCommand(sql);
  }
 
  ResultSet executeQuery(String sql, Object[] params, int maxRows) throws SQLException {
    if (maxRows == 0) {
      QueryResultSet qrs = flashDatabase.executeQuery(sql, params);
      return new JdbcResultSet(qrs);
    }
    return (ResultSet) execute(sql, params, maxRows);
  }
View Full Code Here

   
    this.joinFieldRelate = relateColumn.getName();
    this.isPrimaryKeyR = (isFirstColumnIsUnique && (relateColumn == this.columns[0]));
   
    if (loadData) {
      QueryResultSet qrsData = flashDatabase.executeQuery(dataSql, new Object[0]);
      this.key2rows = readKey2rows(qrsData, joinFieldRelate, isPrimaryKeyR);
    }
    else this.key2rows = null;
  }
View Full Code Here

    this.columns = base.columns;
    this.isPrimaryKeyR = base.isPrimaryKeyR;
    this.fieldMainIsArray = base.fieldMainIsArray;

    String dataSql = base.dataSqlIsComplex ? base.dataSql : (base.dataSql + " where "+ joinFieldRelate + " in ?");
    QueryResultSet qrs = flashDatabase.executeQuery(dataSql, new Object[]{partJoinKeys});
    this.key2rows = readKey2rows(qrs, joinFieldRelate, isPrimaryKeyR);
  }
View Full Code Here

  }

  private FlashDatabase flashDatabase;
 
  public Object queryForObject(String sql) {
    QueryResultSet qrs = flashDatabase.executeQuery(sql, new Object[0]);
    if (qrs.getColumnCount() != 1)
      throw new RuntimeException("Result of queryForObject(...) must be only one column.");
    if (qrs.getRowCount() > 1)
      throw new RuntimeException("Result of queryForObject(...) must be only one row.");
    if (qrs.getRowCount() == 0)
      return null;
    else
      return qrs.fastGetValue(0, 0);
  }
View Full Code Here

    else
      return qrs.fastGetValue(0, 0);
  }
 
  public Set<Object> queryForSet(String sql) {
    QueryResultSet qrs = flashDatabase.executeQuery(sql, new Object[0]);
    if (qrs.getColumnCount() != 1)
      throw new RuntimeException("Result of queryForSet(...) must be only one column.");
    Set<Object> result = new HashSet<Object>();
    for (int i=0; i < qrs.getRowCount(); i++) {
      Object value = qrs.fastGetValue(i, 0);
      if (value == null) continue;
      result.add(value);
    }
    return result;
  }
View Full Code Here

    Object[] keyValues;
    if (mainIsTableName) {
      String mainSql = "select "+mainKeyColumnInfo.getName()+" from "+mainTableOrSql;
      if ((condition != null) && (! condition.isEmpty()))
        mainSql += " where " + condition;
      QueryResultSet qrs = flashDatabase.executeQuery(mainSql, conditionParams != null ? conditionParams : new Object[0]);
      keyValues = new Object[qrs.getRowCount()];
      for (int i=0; i < keyValues.length; i++) {
        keyValues[i] = qrs.getValue(i, 0);
      }
      Arrays.sort(keyValues);
    }
    else {
      QueryResultSet qrs = flashDatabase.executeQuery(mainTableOrSql, conditionParams != null ? conditionParams : new Object[0]);
      keyValues = new Object[qrs.getRowCount()];
      for (int i=0; i < keyValues.length; i++) {
        keyValues[i] = qrs.getRow(i);
      }
    }
   
    // 根据主键分段
    int partCount = (keyValues.length + partSize - 1) / partSize;
View Full Code Here

TOP

Related Classes of com.lingbobu.flashdb.common.QueryResultSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.