private Value convertToUnknownValue(Object x) { checkClosed(); return DataType.convertToValue(conn.getSession(), x, Value.UNKNOWN); }
@Override public Value getValue(Session session) { HashMap<Expression, Object> group = select.getCurrentGroup(); if (group == null) { throw DbException.get(ErrorCode.INVALID_USE_OF_AGGREGATE_FUNCTION_1, getSQL()); } try { Aggregate agg = (Aggregate) group.get(this); if (agg == null) { agg = getInstance(); } Object obj = agg.getResult(); if (obj == null) { return ValueNull.INSTANCE; } return DataType.convertToValue(session, obj, dataType); } catch (SQLException e) { throw DbException.convert(e); } }
/** * Create a new Array object. * * @param typeName the type name * @param elements the values * @return the array */ @Override public Array createArrayOf(String typeName, Object[] elements) throws SQLException { try { int id = getNextId(TraceObject.ARRAY); debugCodeAssign("Array", TraceObject.ARRAY, id, "createArrayOf()"); checkClosed(); Value value = DataType.convertToValue(session, elements, Value.ARRAY); return new JdbcArray(this, value, id); } catch (Exception e) { throw logAndConvert(e); } }
/** * Sets the value of a parameter. * Objects of unknown classes are serialized (on the client side). * * @param parameterIndex the parameter index (1, 2, ...) * @param x the value * @throws SQLException if this object is closed */ @Override public void setObject(int parameterIndex, Object x) throws SQLException { try { if (isDebugEnabled()) { debugCode("setObject("+parameterIndex+", x);"); } if (x == null) { // throw Errors.getInvalidValueException("null", "x"); setParameter(parameterIndex, ValueNull.INSTANCE); } else { setParameter(parameterIndex, DataType.convertToValue(session, x, Value.UNKNOWN)); } } catch (Exception e) { throw logAndConvert(e); } }
Value[] values = new Value[len]; for (int i = 0; i < len; i++) { values[i] = DataType.convertToValue(session, list[i], Value.NULL);
/** * Sets the value of a parameter as an Array. * * @param parameterIndex the parameter index (1, 2, ...) * @param x the value * @throws SQLException if this object is closed */ @Override public void setArray(int parameterIndex, Array x) throws SQLException { try { if (isDebugEnabled()) { debugCode("setArray("+parameterIndex+", x);"); } checkClosed(); Value v; if (x == null) { v = ValueNull.INSTANCE; } else { v = DataType.convertToValue(session, x.getArray(), Value.ARRAY); } setParameter(parameterIndex, v); } catch (Exception e) { throw logAndConvert(e); } }
return (Value) returnValue; Value ret = DataType.convertToValue(session, returnValue, dataType); return ret.convertTo(dataType); } finally {
/** * Sets the value of a parameter. The object is converted, if required, to * the specified data type before sending to the database. * Objects of unknown classes are serialized (on the client side). * * @param parameterIndex the parameter index (1, 2, ...) * @param x the value, null is allowed * @param targetSqlType the type as defined in java.sql.Types * @throws SQLException if this object is closed */ @Override public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException { try { if (isDebugEnabled()) { debugCode("setObject("+parameterIndex+", x, "+targetSqlType+");"); } int type = DataType.convertSQLTypeToValueType(targetSqlType); if (x == null) { setParameter(parameterIndex, ValueNull.INSTANCE); } else { Value v = DataType.convertToValue(conn.getSession(), x, type); setParameter(parameterIndex, v.convertTo(type)); } } catch (Exception e) { throw logAndConvert(e); } }
java.sql.Array array = (java.sql.Array) x; try { return convertToValue(session, array.getArray(), Value.ARRAY); } catch (SQLException e) { throw DbException.convert(e); Value[] v = new Value[len]; for (int i = 0; i < len; i++) { v[i] = convertToValue(session, o[i], type);
Object o = newList[i]; if (o != newListBackup[i]) { Value v = DataType.convertToValue(session, o, Value.UNKNOWN); session.getGeneratedKeys().add(table.getColumn(i)); newRow.setValue(i, v);
private Value convertToUnknownValue(Object x) { checkClosed(); return DataType.convertToValue(conn.getSession(), x, Value.UNKNOWN); }
private Value convertToUnknownValue(Object x) { checkClosed(); return DataType.convertToValue(conn.getSession(), x, Value.UNKNOWN); }
public Value getValue(Session session) throws SQLException { HashMap group = select.getCurrentGroup(); if (group == null) { throw Message.getSQLException(ErrorCode.INVALID_USE_OF_AGGREGATE_FUNCTION_1, getSQL()); } AggregateFunction agg = (AggregateFunction) group.get(this); if (agg == null) { agg = getInstance(); } Object obj = agg.getResult(); if (obj == null) { return ValueNull.INSTANCE; } else { return DataType.convertToValue(session, obj, dataType); } }
/** * Updates a column in the current or insert row. * * @param columnIndex (1,2,...) * @param x the value * @param scale is ignored * @throws SQLException if the result set is closed */ public void updateObject(int columnIndex, Object x, int scale) throws SQLException { try { if (debug()) { debugCode("updateObject("+columnIndex+", x, "+scale+");"); } update(columnIndex, DataType.convertToValue(session, x, Value.UNKNOWN)); } catch (Throwable e) { throw logAndConvert(e); } }
/** * Updates a column in the current or insert row. * * @param columnIndex (1,2,...) * @param x the value * @throws SQLException if the result set is closed */ public void updateObject(int columnIndex, Object x) throws SQLException { try { if (debug()) { debugCode("updateObject("+columnIndex+", x);"); } update(columnIndex, DataType.convertToValue(session, x, Value.UNKNOWN)); } catch (Throwable e) { throw logAndConvert(e); } }
/** * Updates a column in the current or insert row. * * @param columnName the name of the column label * @param x the value * @throws SQLException if the result set is closed */ public void updateObject(String columnName, Object x) throws SQLException { try { if (debug()) { debugCode("updateObject("+quote(columnName)+", x);"); } update(columnName, DataType.convertToValue(session, x, Value.UNKNOWN)); } catch (Throwable e) { throw logAndConvert(e); } }
/** * Updates a column in the current or insert row. * * @param columnName the name of the column label * @param x the value * @param scale is ignored * @throws SQLException if the result set is closed */ public void updateObject(String columnName, Object x, int scale) throws SQLException { try { if (debug()) { debugCode("updateObject("+quote(columnName)+", x, "+scale+");"); } update(columnName, DataType.convertToValue(session, x, Value.UNKNOWN)); } catch (Throwable e) { throw logAndConvert(e); } }
@Override public Row getRow(Session session, long key) { try { Object[] driverRow = driver.getRow(key - 1); Value[] values = new Value[driverRow.length + 1]; Column[] columns = table.getColumns(); values[0] = ValueLong.get(key); for(int idField=1;idField<=driverRow.length;idField++) { // TODO in H2, switch on type parameter instead of if elseif values[idField] = DataType.convertToValue(session, driverRow[idField - 1], columns[idField - 1].getType()); } Row row = session.createRow(values, Row.MEMORY_CALCULATE); row.setKey(key); return row; } catch (IOException ex) { throw DbException.get(ErrorCode.IO_EXCEPTION_1,ex); } }
@Override public Row getRow(Session session, long key) { try { Object[] driverRow = driver.getRow(key - 1); Value[] values = new Value[driverRow.length + 1]; Column[] columns = table.getColumns(); values[0] = ValueLong.get(key); for(int idField=1;idField<=driverRow.length;idField++) { // TODO in H2, switch on type parameter instead of if elseif values[idField] = DataType.convertToValue(session, driverRow[idField - 1], columns[idField - 1].getType()); } Row row = new Row(values, Row.MEMORY_CALCULATE); row.setKey(key); return row; } catch (IOException ex) { throw DbException.get(ErrorCode.IO_EXCEPTION_1,ex); } }
@Override public Row getRow(Session session, long key) { try { Object[] driverRow = driver.getRow(key - 1); Value[] values = new Value[driverRow.length + 1]; Column[] columns = table.getColumns(); values[0] = ValueLong.get(key); for(int idField=1;idField<=driverRow.length;idField++) { // TODO in H2, switch on type parameter instead of if elseif values[idField] = DataType.convertToValue(session, driverRow[idField - 1], columns[idField - 1].getType()); } Row row = session.createRow(values, Row.MEMORY_CALCULATE); row.setKey(key); return row; } catch (IOException ex) { throw DbException.get(ErrorCode.IO_EXCEPTION_1,ex); } }