Exemplo n.º 1
0
 public boolean next() {
   row = null;
   try {
     if (result != null && result.next()) {
       int columnCount = meta.getColumnCount();
       values = new Value[columnCount];
       for (int i = 0; i < columnCount; i++) {
         int type = DataType.convertSQLTypeToValueType(meta.getColumnType(i + 1));
         values[i] = DataType.readValue(session, result, i + 1, type);
       }
     } else {
       values = null;
     }
   } catch (SQLException e) {
     throw DbException.convert(e);
   }
   return values != null;
 }
Exemplo n.º 2
0
 private static SimpleResultSet getSimpleResultSet(ResultInterface rs, int maxrows) {
   int columnCount = rs.getVisibleColumnCount();
   SimpleResultSet simple = new SimpleResultSet();
   for (int i = 0; i < columnCount; i++) {
     String name = rs.getColumnName(i);
     int sqlType = DataType.convertTypeToSQLType(rs.getColumnType(i));
     int precision = MathUtils.convertLongToInt(rs.getColumnPrecision(i));
     int scale = rs.getColumnScale(i);
     simple.addColumn(name, sqlType, precision, scale);
   }
   rs.reset();
   for (int i = 0; i < maxrows && rs.next(); i++) {
     Object[] list = new Object[columnCount];
     for (int j = 0; j < columnCount; j++) {
       list[j] = rs.currentRow()[j].getObject();
     }
     simple.addRow(list);
   }
   return simple;
 }