private static ResultSet getResultSet(Object[] array, long offset) { SimpleResultSet rs = new SimpleResultSet(); rs.addColumn("INDEX", Types.BIGINT, 0, 0); // TODO array result set: there are multiple data types possible rs.addColumn("VALUE", Types.NULL, 0, 0); for (int i = 0; i < array.length; i++) { rs.addRow(offset + i + 1, array[i]); } return rs; }
private void update(int columnIndex, Object obj) throws SQLException { checkColumnIndex(columnIndex); this.currentRow[columnIndex - 1] = obj; }
/** * Returns the value as a java.sql.Array. * * @param columnLabel the column label * @return the value */ @Override public Array getArray(String columnLabel) throws SQLException { return getArray(findColumn(columnLabel)); }
/** * Returns the value as a byte. * * @param columnLabel the column label * @return the value */ @Override public byte getByte(String columnLabel) throws SQLException { return getByte(findColumn(columnLabel)); }
public ResultSet getResultSet() { SimpleResultSet rs = new SimpleResultSet(); rs.setAutoClose(false); rs.addColumn("X", DataType.convertTypeToSQLType(getType()), MathUtils.convertLongToInt(getPrecision()), getScale()); rs.addRow(getObject()); return rs; }
if (wasNull()) { return null; return type.cast(getBigDecimal(columnIndex)); } else if (type == BigInteger.class) { return type.cast(getBigDecimal(columnIndex).toBigInteger()); } else if (type == String.class) { return type.cast(getString(columnIndex)); } else if (type == Boolean.class) { return type.cast(getBoolean(columnIndex)); } else if (type == Byte.class) { return type.cast(getByte(columnIndex)); } else if (type == Short.class) { return type.cast(getShort(columnIndex)); } else if (type == Integer.class) { return type.cast(getInt(columnIndex)); } else if (type == Long.class) { return type.cast(getLong(columnIndex)); } else if (type == Float.class) { return type.cast(getFloat(columnIndex)); } else if (type == Double.class) { return type.cast(getDouble(columnIndex)); } else if (type == Date.class) { return type.cast(getDate(columnIndex)); } else if (type == Time.class) { return type.cast(getTime(columnIndex)); } else if (type == Timestamp.class) { return type.cast(getTimestamp(columnIndex)); } else if (type == UUID.class) {
/** * Create an empty search result and initialize the columns. * * @param data true if the result set should contain the primary key data as * an array. * @return the empty result set */ protected static SimpleResultSet createResultSet(boolean data) { SimpleResultSet result = new SimpleResultSet(); if (data) { result.addColumn(FullText.FIELD_SCHEMA, Types.VARCHAR, 0, 0); result.addColumn(FullText.FIELD_TABLE, Types.VARCHAR, 0, 0); result.addColumn(FullText.FIELD_COLUMNS, Types.ARRAY, 0, 0); result.addColumn(FullText.FIELD_KEYS, Types.ARRAY, 0, 0); } else { result.addColumn(FullText.FIELD_QUERY, Types.VARCHAR, 0, 0); } result.addColumn(FullText.FIELD_SCORE, Types.FLOAT, 0, 0); return result; }
private static void addDatabaseMetaData(SimpleResultSet rs, DatabaseMetaData meta) { Method[] methods = DatabaseMetaData.class.getDeclaredMethods(); Arrays.sort(methods, new Comparator<Method>() { @Override public int compare(Method o1, Method o2) { return o1.toString().compareTo(o2.toString()); } }); for (Method m : methods) { if (m.getParameterTypes().length == 0) { try { Object o = m.invoke(meta); rs.addRow("meta." + m.getName(), "" + o); } catch (InvocationTargetException e) { rs.addRow("meta." + m.getName(), e.getTargetException().toString()); } catch (Exception e) { rs.addRow("meta." + m.getName(), e.toString()); } } } }
/** * Returns the value as a java.sql.Blob. * This is only supported if the * result set was created using a Blob object. * * @param columnIndex (1,2,...) * @return the value */ @Override public Blob getBlob(int columnIndex) throws SQLException { return (Blob) get(columnIndex); }
@Override public Value convertPrecision(long precision, boolean force) { if (!force) { return this; } SimpleResultSet rs = new SimpleResultSet(); rs.setAutoClose(false); return ValueResultSet.get(rs); }
/** * Returns the value as a java.math.BigDecimal. * * @param columnLabel the column label * @return the value */ @Override public BigDecimal getBigDecimal(String columnLabel) throws SQLException { return getBigDecimal(findColumn(columnLabel)); }
/** * Adds a column to the result set. * All columns must be added before adding rows. * This method uses the default SQL type names. * * @param name null is replaced with C1, C2,... * @param sqlType the value returned in getColumnType(..) * @param precision the precision * @param scale the scale */ public void addColumn(String name, int sqlType, int precision, int scale) { int valueType = DataType.convertSQLTypeToValueType(sqlType); addColumn(name, sqlType, DataType.getDataType(valueType).name, precision, scale); }
return new SimpleResultSet();
/** * Returns the value as an Object. * * @param columnLabel the column label * @return the value */ @Override public Object getObject(String columnLabel) throws SQLException { return getObject(findColumn(columnLabel)); }
/** * Returns the value as a byte array. * * @param columnLabel the column label * @return the value */ @Override public byte[] getBytes(String columnLabel) throws SQLException { return getBytes(findColumn(columnLabel)); }
/** * Returns the value as a java.sql.Date. * * @param columnLabel the column label * @return the value */ @Override public Date getDate(String columnLabel) throws SQLException { return getDate(findColumn(columnLabel)); }
/** * Returns the value as a short. * * @param columnLabel the column label * @return the value */ @Override public short getShort(String columnLabel) throws SQLException { return getShort(findColumn(columnLabel)); }
/** * Returns the value as a java.sql.Time. * * @param columnLabel the column label * @return the value */ @Override public Time getTime(String columnLabel) throws SQLException { return getTime(findColumn(columnLabel)); }
/** * Returns the value as a java.sql.Timestamp. * * @param columnLabel the column label * @return the value */ @Override public Timestamp getTimestamp(String columnLabel) throws SQLException { return getTimestamp(findColumn(columnLabel)); }
/** * Returns the value as a double. * * @param columnLabel the column label * @return the value */ @Override public double getDouble(String columnLabel) throws SQLException { return getDouble(findColumn(columnLabel)); }