Search in sources :

Example 11 with ParameterInterface

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

the class JdbcParameterMetaData method getParameterClassName.

/**
 * Returns the Java class name of the parameter.
 * "java.lang.String" is returned if the type is not known.
 *
 * @param param the column index (1,2,...)
 * @return the Java class name
 */
@Override
public String getParameterClassName(int param) throws SQLException {
    try {
        debugCodeCall("getParameterClassName", param);
        ParameterInterface p = getParameter(param);
        int type = p.getType();
        if (type == Value.UNKNOWN) {
            type = Value.STRING;
        }
        return DataType.getTypeClassName(type);
    } catch (Exception e) {
        throw logAndConvert(e);
    }
}
Also used : ParameterInterface(org.h2.expression.ParameterInterface) SQLException(java.sql.SQLException) DbException(org.h2.message.DbException)

Example 12 with ParameterInterface

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

the class JdbcParameterMetaData method getParameterTypeName.

/**
 * Returns the parameter type name.
 * "VARCHAR" is returned if the type is not known.
 *
 * @param param the column index (1,2,...)
 * @return the type name
 */
@Override
public String getParameterTypeName(int param) throws SQLException {
    try {
        debugCodeCall("getParameterTypeName", param);
        ParameterInterface p = getParameter(param);
        int type = p.getType();
        if (type == Value.UNKNOWN) {
            type = Value.STRING;
        }
        return DataType.getDataType(type).name;
    } catch (Exception e) {
        throw logAndConvert(e);
    }
}
Also used : ParameterInterface(org.h2.expression.ParameterInterface) SQLException(java.sql.SQLException) DbException(org.h2.message.DbException)

Example 13 with ParameterInterface

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

the class JdbcCallableStatement method registerOutParameter.

private void registerOutParameter(int parameterIndex) throws SQLException {
    try {
        checkClosed();
        if (outParameters == null) {
            maxOutParameters = Math.min(getParameterMetaData().getParameterCount(), getCheckedMetaData().getColumnCount());
            outParameters = new BitSet();
        }
        checkIndexBounds(parameterIndex);
        ParameterInterface param = command.getParameters().get(--parameterIndex);
        if (!param.isValueSet()) {
            param.setValue(ValueNull.INSTANCE, false);
        }
        outParameters.set(parameterIndex);
    } catch (Exception e) {
        throw logAndConvert(e);
    }
}
Also used : ParameterInterface(org.h2.expression.ParameterInterface) BitSet(java.util.BitSet) DbException(org.h2.message.DbException) SQLException(java.sql.SQLException)

Example 14 with ParameterInterface

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

the class JdbcPreparedStatement method clearParameters.

/**
 * Clears all parameters.
 *
 * @throws SQLException if this object is closed or invalid
 */
@Override
public void clearParameters() throws SQLException {
    try {
        debugCodeCall("clearParameters");
        checkClosed();
        ArrayList<? extends ParameterInterface> parameters = command.getParameters();
        for (ParameterInterface param : parameters) {
            // can only delete old temp files if they are not in the batch
            param.setValue(null, batchParameters == null);
        }
    } catch (Exception e) {
        throw logAndConvert(e);
    }
}
Also used : ParameterInterface(org.h2.expression.ParameterInterface) DbException(org.h2.message.DbException) SQLException(java.sql.SQLException)

Example 15 with ParameterInterface

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

the class JdbcPreparedStatement method setParameter.

// =============================================================
private void setParameter(int parameterIndex, Value value) {
    checkClosed();
    parameterIndex--;
    ArrayList<? extends ParameterInterface> parameters = command.getParameters();
    if (parameterIndex < 0 || parameterIndex >= parameters.size()) {
        throw DbException.getInvalidValueException("parameterIndex", parameterIndex + 1);
    }
    ParameterInterface param = parameters.get(parameterIndex);
    // can only delete old temp files if they are not in the batch
    param.setValue(value, batchParameters == null);
}
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