Search in sources :

Example 6 with ParameterInterface

use of org.h2.expression.ParameterInterface in project h2database by h2database.

the class JdbcParameterMetaData method getPrecision.

/**
 * Returns the parameter precision.
 * The value 0 is returned if the precision is not known.
 *
 * @param param the column index (1,2,...)
 * @return the precision
 */
@Override
public int getPrecision(int param) throws SQLException {
    try {
        debugCodeCall("getPrecision", param);
        ParameterInterface p = getParameter(param);
        return MathUtils.convertLongToInt(p.getPrecision());
    } catch (Exception e) {
        throw logAndConvert(e);
    }
}
Also used : ParameterInterface(org.h2.expression.ParameterInterface) SQLException(java.sql.SQLException) DbException(org.h2.message.DbException)

Example 7 with ParameterInterface

use of org.h2.expression.ParameterInterface in project h2database by h2database.

the class JdbcPreparedStatement method addBatch.

/**
 * Adds the current settings to the batch.
 */
@Override
public void addBatch() throws SQLException {
    try {
        debugCodeCall("addBatch");
        checkClosedForWrite();
        try {
            ArrayList<? extends ParameterInterface> parameters = command.getParameters();
            int size = parameters.size();
            Value[] set = new Value[size];
            for (int i = 0; i < size; i++) {
                ParameterInterface param = parameters.get(i);
                param.checkSet();
                Value value = param.getParamValue();
                set[i] = value;
            }
            if (batchParameters == null) {
                batchParameters = New.arrayList();
            }
            batchParameters.add(set);
        } finally {
            afterWriting();
        }
    } catch (Exception e) {
        throw logAndConvert(e);
    }
}
Also used : ParameterInterface(org.h2.expression.ParameterInterface) Value(org.h2.value.Value) DbException(org.h2.message.DbException) SQLException(java.sql.SQLException)

Example 8 with ParameterInterface

use of org.h2.expression.ParameterInterface in project h2database by h2database.

the class TcpServerThread method setParameters.

private void setParameters(Command command) throws IOException {
    int len = transfer.readInt();
    ArrayList<? extends ParameterInterface> params = command.getParameters();
    for (int i = 0; i < len; i++) {
        Parameter p = (Parameter) params.get(i);
        p.setValue(transfer.readValue());
    }
}
Also used : Parameter(org.h2.expression.Parameter)

Example 9 with ParameterInterface

use of org.h2.expression.ParameterInterface in project h2database by h2database.

the class CommandRemote method sendParameters.

private void sendParameters(Transfer transfer) throws IOException {
    int len = parameters.size();
    transfer.writeInt(len);
    for (ParameterInterface p : parameters) {
        Value pVal = p.getParamValue();
        if (pVal == null && cmdType == EXPLAIN) {
            pVal = ValueNull.INSTANCE;
        }
        transfer.writeValue(pVal);
    }
}
Also used : ParameterInterface(org.h2.expression.ParameterInterface) Value(org.h2.value.Value)

Example 10 with ParameterInterface

use of org.h2.expression.ParameterInterface in project h2database by h2database.

the class Command method reuse.

/**
 * The command is now re-used, therefore reset the canReuse flag, and the
 * parameter values.
 */
public void reuse() {
    canReuse = false;
    ArrayList<? extends ParameterInterface> parameters = getParameters();
    for (ParameterInterface param : parameters) {
        param.setValue(null, true);
    }
}
Also used : ParameterInterface(org.h2.expression.ParameterInterface)

Aggregations

ParameterInterface (org.h2.expression.ParameterInterface)15 DbException (org.h2.message.DbException)10 SQLException (java.sql.SQLException)9 Value (org.h2.value.Value)6 IOException (java.io.IOException)1 ResultSet (java.sql.ResultSet)1 BitSet (java.util.BitSet)1 Parameter (org.h2.expression.Parameter)1 MergedResultSet (org.h2.util.MergedResultSet)1 StatementBuilder (org.h2.util.StatementBuilder)1 Transfer (org.h2.value.Transfer)1