Example usage for java.sql CallableStatement setNull

List of usage examples for java.sql CallableStatement setNull

Introduction

In this page you can find the example usage for java.sql CallableStatement setNull.

Prototype

void setNull(String parameterName, int sqlType, String typeName) throws SQLException;

Source Link

Document

Sets the designated parameter to SQL NULL.

Usage

From source file:org.seasar.dbflute.logic.sql2entity.cmentity.DfProcedureExecutionMetaExtractor.java

protected void bindObject(Connection conn, CallableStatement cs, int paramIndex, int jdbcDefType, Object value,
        DfProcedureColumnMeta column) throws SQLException {
    final ValueType valueType;
    {// www .j  a  v a 2 s  .  c  o  m
        final ValueType forcedType = getForcedValueType(column);
        if (forcedType != null) {
            valueType = forcedType;
        } else {
            valueType = TnValueTypes.findByValueOrJdbcDefType(value, jdbcDefType);
        }
    }
    try {
        if (column.isOracleTreatedAsArray() && column.hasTypeArrayInfo()) {
            cs.setNull(paramIndex, Types.ARRAY, column.getTypeArrayInfo().getTypeSqlName());
        } else if (column.isOracleStruct() && column.hasTypeStructInfo()) {
            cs.setNull(paramIndex, Types.STRUCT, column.getTypeStructInfo().getTypeSqlName());
        } else {
            valueType.bindValue(conn, cs, paramIndex, value);
        }
    } catch (SQLException e) {
        String msg = buildBindingExceptionMessage(paramIndex, jdbcDefType, value, column, valueType);
        throw new DfJDBCException(msg, e);
    } catch (RuntimeException e) {
        String msg = buildBindingExceptionMessage(paramIndex, jdbcDefType, value, column, valueType);
        throw new IllegalStateException(msg, e);
    }
}