Example usage for java.sql Types TINYINT

List of usage examples for java.sql Types TINYINT

Introduction

In this page you can find the example usage for java.sql Types TINYINT.

Prototype

int TINYINT

To view the source code for java.sql Types TINYINT.

Click Source Link

Document

The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type TINYINT.

Usage

From source file:org.nuxeo.ecm.core.storage.sql.db.H2Fulltext.java

protected static String asString(Object data, int type) throws SQLException {
    if (data == null) {
        return "";
    }//from  w  ww.  ja  va 2 s . co  m
    switch (type) {
    case Types.BIT:
    case Types.BOOLEAN:
    case Types.INTEGER:
    case Types.BIGINT:
    case Types.DECIMAL:
    case Types.DOUBLE:
    case Types.FLOAT:
    case Types.NUMERIC:
    case Types.REAL:
    case Types.SMALLINT:
    case Types.TINYINT:
    case Types.DATE:
    case Types.TIME:
    case Types.TIMESTAMP:
    case Types.LONGVARCHAR:
    case Types.CHAR:
    case Types.VARCHAR:
        return data.toString();
    case Types.CLOB:
        try {
            if (data instanceof Clob) {
                data = ((Clob) data).getCharacterStream();
            }
            return IOUtils.readStringAndClose((Reader) data, -1);
        } catch (IOException e) {
            throw DbException.convert(e);
        }
    case Types.VARBINARY:
    case Types.LONGVARBINARY:
    case Types.BINARY:
    case Types.JAVA_OBJECT:
    case Types.OTHER:
    case Types.BLOB:
    case Types.STRUCT:
    case Types.REF:
    case Types.NULL:
    case Types.ARRAY:
    case Types.DATALINK:
    case Types.DISTINCT:
        throw new SQLException("Unsupported column data type: " + type);
    default:
        return "";
    }
}

From source file:com.antsdb.saltedfish.server.mysql.PacketEncoder.java

private void writeValueSlow(ByteBuf buffer, FieldMeta meta, long pValue) {
    Object value = FishObject.get(null, pValue);
    DataType type = meta.getType();/*from w  w  w.  j  ava2s.  co m*/
    if (type.getSqlType() == Types.TINYINT) {
        buffer.writeByte((Integer) value);
    } else if (type.getJavaType() == Integer.class) {
        BufferUtils.writeUB4(buffer, (Integer) value);
    } else if (type.getJavaType() == Long.class) {
        BufferUtils.writeLongLong(buffer, (Long) value);
    } else if (type.getJavaType() == Float.class) {
        BufferUtils.writeUB4(buffer, Float.floatToIntBits((Float) value));
    } else if (type.getJavaType() == Double.class) {
        BufferUtils.writeLongLong(buffer, Double.doubleToLongBits((Double) value));
    } else if (type.getJavaType() == Timestamp.class) {
        BufferUtils.writeTimestamp(buffer, (Timestamp) value);
    } else if (type.getJavaType() == Date.class) {
        BufferUtils.writeDate(buffer, (Date) value);
    } else if (type.getJavaType() == byte[].class) {
        BufferUtils.writeWithLength(buffer, (byte[]) value);
    } else {
        BufferUtils.writeLenString(buffer, value.toString(), this.cs);
    }
}

From source file:org.apache.ode.bpel.extvar.jdbc.JdbcExternalVariableModule.java

private Object downcastValue(Object value, int dataType) {
    if (value == null) {
        return null;
    }/*  w w w.j  av  a 2 s  .  c  o m*/
    // Try down casting the value as per its column type.
    try {
        // Some JDBC 4.0 types have been ignored to avoid compilation errors
        switch (dataType) {
        case Types.ARRAY:
            break;
        case Types.BIGINT:
            if (!(value instanceof BigInteger)) {
                value = new BigDecimal(value.toString()).longValue();
            }
            break;
        case Types.BINARY:
            break;
        case Types.BIT:
            if (!(value instanceof Boolean)) {
                value = new Boolean(value.toString());
            }
            break;
        case Types.BLOB:
            break;
        case Types.BOOLEAN:
            if (!(value instanceof Boolean)) {
                value = new Boolean(value.toString());
            }
            break;
        case Types.CHAR:
            break;
        case Types.CLOB:
            break;
        case Types.DATALINK:
            break;
        case Types.DATE:
            break;
        case Types.DECIMAL:
            //ODE-872: Oracle 9g and 10g has problems with BigDecimal on Java1.5
            value = new BigDecimal(new BigDecimal(value.toString()).toPlainString());
            break;
        case Types.DISTINCT:
            break;
        case Types.DOUBLE:
            if (!(value instanceof Double)) {
                value = Double.valueOf(value.toString()).doubleValue();
            }
            break;
        case Types.FLOAT:
            if (!(value instanceof Float)) {
                value = Float.valueOf(value.toString()).floatValue();
            }
            break;
        case Types.INTEGER:
            if (!(value instanceof Integer)) {
                value = Double.valueOf(value.toString()).intValue();
            }
            break;
        case Types.JAVA_OBJECT:
            break;
        //          case Types.LONGNVARCHAR:
        //             break;
        case Types.LONGVARBINARY:
            break;
        case Types.LONGVARCHAR:
            break;
        //          case Types.NCHAR:
        //             break;
        //          case Types.NCLOB:
        //             break;
        case Types.NUMERIC:
            //ODE-872: Oracle 9g and 10g has problems with BigDecimal on Java1.5
            value = new BigDecimal(new BigDecimal(value.toString()).toPlainString());
            break;
        //          case Types.NVARCHAR:
        //             break;
        case Types.OTHER:
            break;
        case Types.REAL:
            if (!(value instanceof Double)) {
                value = Float.valueOf(value.toString()).floatValue();
            }
            break;
        case Types.REF:
            break;
        //          case Types.ROWID:
        //             break;
        case Types.SMALLINT:
            if (!(value instanceof Short)) {
                value = new Short(value.toString()).shortValue();
            }
            break;
        //          case Types.SQLXML:
        //             break;
        case Types.STRUCT:
            break;
        case Types.TIME:
            break;
        case Types.TIMESTAMP:
            break;
        case Types.TINYINT:
            if (!(value instanceof Short)) {
                value = new Short(value.toString()).shortValue();
            }
            break;
        case Types.VARBINARY:
            break;
        case Types.VARCHAR:
            break;
        default:
            break;
        }
    } catch (Exception e) {
        // couldn't cast... let's just use original value object
    }
    return value;
}

From source file:com.streamsets.pipeline.lib.jdbc.multithread.TableContextUtil.java

public static String generateNextPartitionOffset(TableContext tableContext, String column, String offset) {
    final String partitionSize = tableContext.getOffsetColumnToPartitionOffsetAdjustments().get(column);
    switch (tableContext.getOffsetColumnToType().get(column)) {
    case Types.TINYINT:
    case Types.SMALLINT:
    case Types.INTEGER:
        final int int1 = Integer.parseInt(offset);
        final int int2 = Integer.parseInt(partitionSize);
        return String.valueOf(int1 + int2);
    case Types.TIMESTAMP:
        final Timestamp timestamp1 = getTimestampForOffsetValue(offset);
        final long timestampAdj = Long.parseLong(partitionSize);
        final Timestamp timestamp2 = Timestamp.from(timestamp1.toInstant().plusMillis(timestampAdj));
        return getOffsetValueForTimestamp(timestamp2);
    case Types.BIGINT:
        // TIME, DATE are represented as long (epoch)
    case Types.TIME:
    case Types.DATE:
        final long long1 = Long.parseLong(offset);
        final long long2 = Long.parseLong(partitionSize);
        return String.valueOf(long1 + long2);
    case Types.FLOAT:
    case Types.REAL:
        final float float1 = Float.parseFloat(offset);
        final float float2 = Float.parseFloat(partitionSize);
        return String.valueOf(float1 + float2);
    case Types.DOUBLE:
        final double double1 = Double.parseDouble(offset);
        final double double2 = Double.parseDouble(partitionSize);
        return String.valueOf(double1 + double2);
    case Types.NUMERIC:
    case Types.DECIMAL:
        final BigDecimal decimal1 = new BigDecimal(offset);
        final BigDecimal decimal2 = new BigDecimal(partitionSize);
        return decimal1.add(decimal2).toString();
    }/*ww  w.j  a  v a  2s.  c  o m*/
    return null;
}

From source file:org.waarp.common.database.data.AbstractDbData.java

/**
 * Create the equivalent object in Json (no database access)
 * /* w  ww  .j  a  v a  2 s .  c o  m*/
 * @return The ObjectNode Json equivalent
 */
public ObjectNode getJson() {
    ObjectNode node = JsonHandler.createObjectNode();
    node.put(JSON_MODEL, this.getClass().getSimpleName());
    for (DbValue value : allFields) {
        if (value.column.equalsIgnoreCase("UPDATEDINFO")) {
            continue;
        }
        switch (value.type) {
        case Types.VARCHAR:
        case Types.LONGVARCHAR:
            node.put(value.column, (String) value.value);
            break;
        case Types.BIT:
            node.put(value.column, (Boolean) value.value);
            break;
        case Types.TINYINT:
            node.put(value.column, (Byte) value.value);
            break;
        case Types.SMALLINT:
            node.put(value.column, (Short) value.value);
            break;
        case Types.INTEGER:
            node.put(value.column, (Integer) value.value);
            break;
        case Types.BIGINT:
            node.put(value.column, (Long) value.value);
            break;
        case Types.REAL:
            node.put(value.column, (Float) value.value);
            break;
        case Types.DOUBLE:
            node.put(value.column, (Double) value.value);
            break;
        case Types.VARBINARY:
            node.put(value.column, (byte[]) value.value);
            break;
        case Types.DATE:
            node.put(value.column, ((Date) value.value).getTime());
            break;
        case Types.TIMESTAMP:
            node.put(value.column, ((Timestamp) value.value).getTime());
            break;
        case Types.CLOB:
        case Types.BLOB:
        default:
            node.put(value.column, "Unsupported type=" + value.type);
        }
    }
    return node;
}

From source file:org.sakaiproject.warehouse.util.db.DbLoader.java

protected int getJavaSqlType(String genericDataTypeName) {
    // Find the type code for this generic type name
    int dataTypeCode = 0;

    if (genericDataTypeName.equalsIgnoreCase("BIT"))
        dataTypeCode = Types.BIT; // -7
    else if (genericDataTypeName.equalsIgnoreCase("TINYINT"))
        dataTypeCode = Types.TINYINT; // -6
    else if (genericDataTypeName.equalsIgnoreCase("SMALLINT"))
        dataTypeCode = Types.SMALLINT; // 5
    else if (genericDataTypeName.equalsIgnoreCase("INTEGER"))
        dataTypeCode = Types.INTEGER; // 4
    else if (genericDataTypeName.equalsIgnoreCase("BIGINT"))
        dataTypeCode = Types.BIGINT; // -5
    else if (genericDataTypeName.equalsIgnoreCase("FLOAT"))
        dataTypeCode = Types.FLOAT; // 6
    else if (genericDataTypeName.equalsIgnoreCase("REAL"))
        dataTypeCode = Types.REAL; // 7
    else if (genericDataTypeName.equalsIgnoreCase("DOUBLE"))
        dataTypeCode = Types.DOUBLE; // 8
    else if (genericDataTypeName.equalsIgnoreCase("NUMERIC"))
        dataTypeCode = Types.NUMERIC; // 2
    else if (genericDataTypeName.equalsIgnoreCase("DECIMAL"))
        dataTypeCode = Types.DECIMAL; // 3

    else if (genericDataTypeName.equalsIgnoreCase("CHAR"))
        dataTypeCode = Types.CHAR; // 1
    else if (genericDataTypeName.equalsIgnoreCase("VARCHAR"))
        dataTypeCode = Types.VARCHAR; // 12
    else if (genericDataTypeName.equalsIgnoreCase("LONGVARCHAR"))
        dataTypeCode = Types.LONGVARCHAR; // -1

    else if (genericDataTypeName.equalsIgnoreCase("DATE"))
        dataTypeCode = Types.DATE; // 91
    else if (genericDataTypeName.equalsIgnoreCase("TIME"))
        dataTypeCode = Types.TIME; // 92
    else if (genericDataTypeName.equalsIgnoreCase("TIMESTAMP"))
        dataTypeCode = Types.TIMESTAMP; // 93

    else if (genericDataTypeName.equalsIgnoreCase("BINARY"))
        dataTypeCode = Types.BINARY; // -2
    else if (genericDataTypeName.equalsIgnoreCase("VARBINARY"))
        dataTypeCode = Types.VARBINARY; // -3
    else if (genericDataTypeName.equalsIgnoreCase("LONGVARBINARY"))
        dataTypeCode = Types.LONGVARBINARY; // -4

    else if (genericDataTypeName.equalsIgnoreCase("NULL"))
        dataTypeCode = Types.NULL; // 0

    else if (genericDataTypeName.equalsIgnoreCase("OTHER"))
        dataTypeCode = Types.OTHER; // 1111

    else if (genericDataTypeName.equalsIgnoreCase("JAVA_OBJECT"))
        dataTypeCode = Types.JAVA_OBJECT; // 2000
    else if (genericDataTypeName.equalsIgnoreCase("DISTINCT"))
        dataTypeCode = Types.DISTINCT; // 2001
    else if (genericDataTypeName.equalsIgnoreCase("STRUCT"))
        dataTypeCode = Types.STRUCT; // 2002

    else if (genericDataTypeName.equalsIgnoreCase("ARRAY"))
        dataTypeCode = Types.ARRAY; // 2003
    else if (genericDataTypeName.equalsIgnoreCase("BLOB"))
        dataTypeCode = Types.BLOB; // 2004
    else if (genericDataTypeName.equalsIgnoreCase("CLOB"))
        dataTypeCode = Types.CLOB; // 2005
    else if (genericDataTypeName.equalsIgnoreCase("REF"))
        dataTypeCode = Types.REF; // 2006

    return dataTypeCode;
}

From source file:org.wso2.carbon.dataservices.core.odata.RDBMSDataHandler.java

/**
 * This method bind values to prepared statement.
 *
 * @param type            data Type//from  w  w w .jav  a  2 s. co  m
 * @param value           String value
 * @param ordinalPosition Ordinal Position
 * @param sqlStatement    Statement
 * @throws SQLException
 * @throws ParseException
 * @throws ODataServiceFault
 */
private void bindValuesToPreparedStatement(int type, String value, int ordinalPosition,
        PreparedStatement sqlStatement) throws SQLException, ParseException, ODataServiceFault {
    byte[] data;
    try {
        switch (type) {
        case Types.INTEGER:
            if (value == null) {
                sqlStatement.setNull(ordinalPosition, type);
            } else {
                sqlStatement.setInt(ordinalPosition, ConverterUtil.convertToInt(value));
            }
            break;
        case Types.TINYINT:
            if (value == null) {
                sqlStatement.setNull(ordinalPosition, type);
            } else {
                sqlStatement.setByte(ordinalPosition, ConverterUtil.convertToByte(value));
            }
            break;
        case Types.SMALLINT:
            if (value == null) {
                sqlStatement.setNull(ordinalPosition, type);
            } else {
                sqlStatement.setShort(ordinalPosition, ConverterUtil.convertToShort(value));
            }
            break;
        case Types.DOUBLE:
            if (value == null) {
                sqlStatement.setNull(ordinalPosition, type);
            } else {
                sqlStatement.setDouble(ordinalPosition, ConverterUtil.convertToDouble(value));
            }
            break;
        case Types.VARCHAR:
            /* fall through */
        case Types.CHAR:
            /* fall through */
        case Types.LONGVARCHAR:
            if (value == null) {
                sqlStatement.setNull(ordinalPosition, type);
            } else {
                sqlStatement.setString(ordinalPosition, value);
            }
            break;
        case Types.CLOB:
            if (value == null) {
                sqlStatement.setNull(ordinalPosition, type);
            } else {
                sqlStatement.setClob(ordinalPosition, new BufferedReader(new StringReader(value)),
                        value.length());
            }
            break;
        case Types.BOOLEAN:
            /* fall through */
        case Types.BIT:
            if (value == null) {
                sqlStatement.setNull(ordinalPosition, type);
            } else {
                sqlStatement.setBoolean(ordinalPosition, ConverterUtil.convertToBoolean(value));
            }
            break;
        case Types.BLOB:
            /* fall through */
        case Types.LONGVARBINARY:
            if (value == null) {
                sqlStatement.setNull(ordinalPosition, type);
            } else {
                data = this.getBytesFromBase64String(value);
                sqlStatement.setBlob(ordinalPosition, new ByteArrayInputStream(data), data.length);
            }
            break;
        case Types.BINARY:
            /* fall through */
        case Types.VARBINARY:
            if (value == null) {
                sqlStatement.setNull(ordinalPosition, type);
            } else {
                data = this.getBytesFromBase64String(value);
                sqlStatement.setBinaryStream(ordinalPosition, new ByteArrayInputStream(data), data.length);
            }
            break;
        case Types.DATE:
            if (value == null) {
                sqlStatement.setNull(ordinalPosition, type);
            } else {
                sqlStatement.setDate(ordinalPosition, DBUtils.getDate(value));
            }
            break;
        case Types.DECIMAL:
            /* fall through */
        case Types.NUMERIC:
            if (value == null) {
                sqlStatement.setNull(ordinalPosition, type);
            } else {
                sqlStatement.setBigDecimal(ordinalPosition, ConverterUtil.convertToBigDecimal(value));
            }
            break;
        case Types.FLOAT:
            /* fall through */
        case Types.REAL:
            if (value == null) {
                sqlStatement.setNull(ordinalPosition, type);
            } else {
                sqlStatement.setFloat(ordinalPosition, ConverterUtil.convertToFloat(value));
            }
            break;
        case Types.TIME:
            if (value == null) {
                sqlStatement.setNull(ordinalPosition, type);
            } else {
                sqlStatement.setTime(ordinalPosition, DBUtils.getTime(value));
            }
            break;
        case Types.LONGNVARCHAR:
            /* fall through */
        case Types.NCHAR:
            /* fall through */
        case Types.NVARCHAR:
            if (value == null) {
                sqlStatement.setNull(ordinalPosition, type);
            } else {
                sqlStatement.setNString(ordinalPosition, value);
            }
            break;
        case Types.NCLOB:
            if (value == null) {
                sqlStatement.setNull(ordinalPosition, type);
            } else {
                sqlStatement.setNClob(ordinalPosition, new BufferedReader(new StringReader(value)),
                        value.length());
            }
            break;
        case Types.BIGINT:
            if (value == null) {
                sqlStatement.setNull(ordinalPosition, type);
            } else {
                sqlStatement.setLong(ordinalPosition, ConverterUtil.convertToLong(value));
            }
            break;
        case Types.TIMESTAMP:
            if (value == null) {
                sqlStatement.setNull(ordinalPosition, type);
            } else {
                sqlStatement.setTimestamp(ordinalPosition, DBUtils.getTimestamp(value));
            }
            break;
        default:
            if (value == null) {
                sqlStatement.setNull(ordinalPosition, type);
            } else {
                sqlStatement.setString(ordinalPosition, value);
            }
            break;
        }
    } catch (DataServiceFault e) {
        throw new ODataServiceFault(e, "Error occurred while binding values. :" + e.getMessage());
    }
}

From source file:org.executequery.gui.resultset.ResultSetTableModel.java

public Class<?> getColumnClass(int column) {

    if (tableData.isEmpty()) {

        return String.class;
    }//from w w w . j  av a2s.  c o  m

    RecordDataItem recordDataItem = tableData.get(0).get(column);
    if (recordDataItem.isValueNull()) {

        return String.class;
    }

    int columnType = recordDataItem.getDataType();
    switch (columnType) {

    case Types.TINYINT:
        return Byte.class;

    case Types.BIGINT:
        return Long.class;

    case Types.SMALLINT:
        return Short.class;

    case Types.BIT:
    case Types.LONGVARCHAR:
    case Types.CHAR:
    case Types.VARCHAR:
    case Types.BOOLEAN: // don't display the checkbox
        return String.class;

    case Types.NUMERIC:
    case Types.DECIMAL:
        return BigDecimal.class;

    case Types.INTEGER:
        return Integer.class;

    case Types.DATE:
    case Types.TIME:
    case Types.TIMESTAMP:
        return java.util.Date.class;

    case Types.REAL:
        return Float.class;

    case Types.FLOAT:
    case Types.DOUBLE:
        return Double.class;

    default:
        return Object.class;

    }

}

From source file:com.netspective.axiom.sql.StoredProcedureParameter.java

/**
 * Extract the OUT parameter values from the callable statment and
 * assign them to the value of the parameter.
 *///from   w  w w.  j  a  v a 2s.c om
public void extract(ConnectionContext cc, CallableStatement stmt) throws SQLException {
    if (getType().getValueIndex() == StoredProcedureParameter.Type.IN)
        return;

    int index = this.getIndex();
    QueryParameterType paramType = getSqlType();
    int jdbcType = paramType.getJdbcType();
    String identifier = paramType.getIdentifier();

    // result sets are special
    if (identifier.equals(QueryParameterType.RESULTSET_IDENTIFIER)) {
        ResultSet rs = (ResultSet) stmt.getObject(index);
        QueryResultSet qrs = new QueryResultSet(getParent().getProcedure(), cc, rs);
        value.getValue(cc).setValue(qrs);
        return;
    }

    switch (jdbcType) {
    case Types.VARCHAR:
        value.getValue(cc).setTextValue(stmt.getString(index));
        break;
    case Types.INTEGER:
        value.getValue(cc).setValue(new Integer(stmt.getInt(index)));
        break;
    case Types.DOUBLE:
        value.getValue(cc).setValue(new Double(stmt.getDouble(index)));
        break;
    case Types.CLOB:
        Clob clob = stmt.getClob(index);
        value.getValue(cc).setTextValue(clob.getSubString(1, (int) clob.length()));
        break;
    case java.sql.Types.ARRAY:
        Array array = stmt.getArray(index);
        value.getValue(cc).setValue(array);
        break;
    case java.sql.Types.BIGINT:
        long bigint = stmt.getLong(index);
        value.getValue(cc).setValue(new Long(bigint));
        break;
    case java.sql.Types.BINARY:
        value.getValue(cc).setTextValue(new String(stmt.getBytes(index)));
        break;
    case java.sql.Types.BIT:
        boolean bit = stmt.getBoolean(index);
        value.getValue(cc).setValue(new Boolean(bit));
    case java.sql.Types.BLOB:
        value.getValue(cc).setValue(stmt.getBlob(index));
        break;
    case java.sql.Types.CHAR:
        value.getValue(cc).setTextValue(stmt.getString(index));
        break;
    case java.sql.Types.DATE:
        value.getValue(cc).setValue(stmt.getDate(index));
        break;
    case java.sql.Types.DECIMAL:
        value.getValue(cc).setValue(stmt.getBigDecimal(index));
        break;
    case java.sql.Types.DISTINCT:
        value.getValue(cc).setValue(stmt.getObject(index));
        break;
    case java.sql.Types.FLOAT:
        value.getValue(cc).setValue(new Float(stmt.getFloat(index)));
        break;
    case java.sql.Types.JAVA_OBJECT:
        value.getValue(cc).setValue(stmt.getObject(index));
        break;
    case java.sql.Types.LONGVARBINARY:
        value.getValue(cc).setTextValue(new String(stmt.getBytes(index)));
        break;
    case java.sql.Types.LONGVARCHAR:
        value.getValue(cc).setTextValue(stmt.getString(index));
        break;
    //case java.sql.Types.NULL:
    //    value.getValue(cc).setValue(null);
    //    break;
    case java.sql.Types.NUMERIC:
        value.getValue(cc).setValue(stmt.getBigDecimal(index));
        break;
    case java.sql.Types.OTHER:
        value.getValue(cc).setValue(stmt.getObject(index));
        break;
    case java.sql.Types.REAL:
        value.getValue(cc).setValue(new Float(stmt.getFloat(index)));
        break;
    //case java.sql.Types.REF:
    //    Ref ref = stmt.getRef(index);
    //    break;
    case java.sql.Types.SMALLINT:
        short sh = stmt.getShort(index);
        value.getValue(cc).setValue(new Short(sh));
        break;
    case java.sql.Types.STRUCT:
        value.getValue(cc).setValue(stmt.getObject(index));
        break;
    case java.sql.Types.TIME:
        value.getValue(cc).setValue(stmt.getTime(index));
        break;
    case java.sql.Types.TIMESTAMP:
        value.getValue(cc).setValue(stmt.getTimestamp(index));
        break;
    case java.sql.Types.TINYINT:
        byte b = stmt.getByte(index);
        value.getValue(cc).setValue(new Byte(b));
        break;
    case java.sql.Types.VARBINARY:
        value.getValue(cc).setValue(stmt.getBytes(index));
        break;
    default:
        throw new RuntimeException(
                "Unknown JDBC Type set for stored procedure parameter '" + this.getName() + "'.");
    }
}

From source file:org.apache.openjpa.jdbc.schema.Column.java

/**
 * Return true if this column is compatible with the given JDBC type
 * from {@link Types} and size.//from w ww  . ja  v  a2 s  .  c  o m
 */
public boolean isCompatible(int type, String typeName, int size, int decimals) {
    if (type == Types.OTHER || getType() == Types.OTHER)
        return true;

    // note that the given size is currently ignored, but may be useful
    // to dynamically-populating subclasses
    switch (getType()) {
    case Types.BIT:
    case Types.TINYINT:
    case Types.BIGINT:
    case Types.INTEGER:
    case Types.NUMERIC:
    case Types.SMALLINT:
    case Types.DECIMAL:
    case Types.DOUBLE:
    case Types.FLOAT:
    case Types.REAL:
        switch (type) {
        case Types.BIT:
        case Types.TINYINT:
        case Types.BIGINT:
        case Types.INTEGER:
        case Types.NUMERIC:
        case Types.SMALLINT:
        case Types.DECIMAL:
        case Types.DOUBLE:
        case Types.FLOAT:
        case Types.REAL:
            return true;
        default:
            return false;
        }
    case Types.BINARY:
    case Types.BLOB:
    case Types.LONGVARBINARY:
    case Types.VARBINARY:
    case Types.OTHER:
        switch (type) {
        case Types.BINARY:
        case Types.BLOB:
        case Types.LONGVARBINARY:
        case Types.VARBINARY:
        case Types.OTHER:
            return true;
        default:
            return false;
        }
    case Types.CLOB:
    case Types.CHAR:
    case Types.LONGVARCHAR:
    case Types.VARCHAR:
        switch (type) {
        case Types.CLOB:
        case Types.CHAR:
        case Types.LONGVARCHAR:
        case Types.VARCHAR:
        case Types.DATE:
        case Types.TIME:
        case Types.TIMESTAMP:
            return true;
        default:
            return false;
        }
    case Types.DATE:
    case Types.TIME:
    case Types.TIMESTAMP:
        switch (type) {
        case Types.LONGVARCHAR:
        case Types.CLOB:
        case Types.VARCHAR:
        case Types.DATE:
        case Types.TIME:
        case Types.TIMESTAMP:
            return true;
        default:
            return false;
        }
    case 2007: // Oracle-defined opaque type code for XMLType
        switch (type) {
        case Types.CHAR:
        case Types.LONGVARCHAR:
        case Types.VARCHAR:
        case Types.CLOB:
        case Types.BLOB:
            return true;
        default:
            return false;
        }

    default:
        return type == getType();
    }
}