Example usage for java.sql Types REAL

List of usage examples for java.sql Types REAL

Introduction

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

Prototype

int REAL

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

Click Source Link

Document

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

Usage

From source file:jeeves.resources.dbms.Dbms.java

private Element buildElement(ResultSet rs, int col, String name, int type, Hashtable<String, String> formats)
        throws SQLException {
    String value = null;//  www  . java2 s. c  om

    switch (type) {
    case Types.DATE:
        Date date = rs.getDate(col + 1);
        if (date == null)
            value = null;
        else {
            String format = formats.get(name);
            SimpleDateFormat df = (format == null) ? new SimpleDateFormat(DEFAULT_DATE_FORMAT)
                    : new SimpleDateFormat(format);
            value = df.format(date);
        }
        break;

    case Types.TIME:
        Time time = rs.getTime(col + 1);
        if (time == null)
            value = null;
        else {
            String format = formats.get(name);
            SimpleDateFormat df = (format == null) ? new SimpleDateFormat(DEFAULT_TIME_FORMAT)
                    : new SimpleDateFormat(format);
            value = df.format(time);
        }
        break;

    case Types.TIMESTAMP:
        Timestamp timestamp = rs.getTimestamp(col + 1);
        if (timestamp == null)
            value = null;
        else {
            String format = formats.get(name);
            SimpleDateFormat df = (format == null) ? new SimpleDateFormat(DEFAULT_TIMESTAMP_FORMAT)
                    : new SimpleDateFormat(format);
            value = df.format(timestamp);
        }
        break;

    case Types.TINYINT:
    case Types.SMALLINT:
    case Types.INTEGER:
    case Types.BIGINT:
        long l = rs.getLong(col + 1);
        if (rs.wasNull())
            value = null;
        else {
            String format = formats.get(name);
            if (format == null)
                value = l + "";
            else {
                DecimalFormat df = new DecimalFormat(format);
                value = df.format(l);
            }
        }
        break;

    case Types.DECIMAL:
    case Types.FLOAT:
    case Types.DOUBLE:
    case Types.REAL:
    case Types.NUMERIC:
        double n = rs.getDouble(col + 1);

        if (rs.wasNull())
            value = null;
        else {
            String format = formats.get(name);

            if (format == null) {
                value = n + "";

                // --- this fix is mandatory for oracle
                // --- that shit returns integers like xxx.0

                if (value.endsWith(".0"))
                    value = value.substring(0, value.length() - 2);
            } else {
                DecimalFormat df = new DecimalFormat(format);
                value = df.format(n);
            }
        }
        break;

    default:
        value = rs.getString(col + 1);
        if (value != null) {
            value = stripIllegalChars(value);
        }

        break;
    }
    return new Element(name).setText(value);
}

From source file:org.jumpmind.vaadin.ui.common.CommonUiUtils.java

@SuppressWarnings("unchecked")
public static Grid putResultsInGrid(final ResultSet rs, List<Integer> pkcolumns, int maxResultSize,
        final boolean showRowNumbers, String... excludeValues) throws SQLException {

    final Grid grid = new Grid();
    grid.setImmediate(true);/*  w  w  w  . ja  v a2  s .  c om*/
    grid.setSelectionMode(SelectionMode.MULTI);
    grid.setColumnReorderingAllowed(true);
    grid.setData(new HashMap<Object, List<Object>>());

    final ResultSetMetaData meta = rs.getMetaData();
    int columnCount = meta.getColumnCount();
    grid.addColumn("#", Integer.class).setHeaderCaption("#").setHidable(true);
    Set<String> columnNames = new HashSet<String>();
    Set<Integer> skipColumnIndexes = new HashSet<Integer>();
    int[] types = new int[columnCount];
    for (int i = 1; i <= columnCount; i++) {
        String realColumnName = meta.getColumnName(i);
        String columnName = realColumnName;
        if (!Arrays.asList(excludeValues).contains(columnName)) {

            int index = 1;
            while (columnNames.contains(columnName)) {
                columnName = realColumnName + "_" + index++;
            }
            columnNames.add(columnName);

            Class<?> typeClass = Object.class;
            int type = meta.getColumnType(i);
            types[i - 1] = type;
            switch (type) {
            case Types.FLOAT:
            case Types.DOUBLE:
            case Types.NUMERIC:
            case Types.REAL:
            case Types.DECIMAL:
                typeClass = BigDecimal.class;
                break;
            case Types.TINYINT:
            case Types.SMALLINT:
            case Types.BIGINT:
            case Types.INTEGER:
                typeClass = Long.class;
                break;
            case Types.VARCHAR:
            case Types.CHAR:
            case Types.NVARCHAR:
            case Types.NCHAR:
            case Types.CLOB:
                typeClass = String.class;
            default:
                break;
            }
            Column column = grid.addColumn(columnName, typeClass).setHeaderCaption(columnName).setHidable(true);
            if (typeClass.equals(Long.class)) {
                column.setConverter(new StringToLongConverter() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public String convertToPresentation(Long value, Class<? extends String> targetType,
                            Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
                        if (value == null) {
                            return NULL_TEXT;
                        } else {
                            return value.toString();
                        }
                    }
                });
            } else if (typeClass.equals(BigDecimal.class)) {
                column.setConverter(new StringToBigDecimalConverter() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public String convertToPresentation(BigDecimal value, Class<? extends String> targetType,
                            Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
                        if (value == null) {
                            return NULL_TEXT;
                        } else {
                            return value.toString();
                        }
                    }
                });
            } else {
                column.setConverter(new Converter<String, Object>() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public Object convertToModel(String value, Class<? extends Object> targetType,
                            Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
                        return null;
                    }

                    @Override
                    public String convertToPresentation(Object value, Class<? extends String> targetType,
                            Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
                        if (value == null) {
                            return NULL_TEXT;
                        } else {
                            return value.toString();
                        }
                    }

                    @Override
                    public Class<Object> getModelType() {
                        return Object.class;
                    }

                    @Override
                    public Class<String> getPresentationType() {
                        return String.class;
                    }

                });
            }
        } else {
            skipColumnIndexes.add(i - 1);
        }

    }
    int rowNumber = 1;
    while (rs.next() && rowNumber <= maxResultSize) {
        Object[] row = new Object[columnNames.size() + 1];
        row[0] = new Integer(rowNumber);
        int rowIndex = 1;
        for (int i = 0; i < columnCount; i++) {
            if (!skipColumnIndexes.contains(i)) {
                Object o = getObject(rs, i + 1);
                int type = types[i];
                switch (type) {
                case Types.FLOAT:
                case Types.DOUBLE:
                case Types.REAL:
                case Types.NUMERIC:
                case Types.DECIMAL:
                    if (o != null && !(o instanceof BigDecimal)) {
                        o = new BigDecimal(castToNumber(o.toString()));
                    }
                    break;
                case Types.TINYINT:
                case Types.SMALLINT:
                case Types.BIGINT:
                case Types.INTEGER:
                    if (o != null && !(o instanceof Long)) {
                        o = new Long(castToNumber(o.toString()));
                    }
                    break;
                default:
                    break;
                }
                List<Object> primaryKeys = new ArrayList<Object>();
                for (Integer pkcolumn : pkcolumns) {
                    primaryKeys.add(getObject(rs, pkcolumn + 1));
                }
                ((HashMap<Object, List<Object>>) grid.getData()).put(o, primaryKeys);
                row[rowIndex] = o;
                rowIndex++;
            }
        }
        grid.addRow(row);
        rowNumber++;
    }

    if (rowNumber < 100) {
        grid.getColumn("#").setWidth(75);
    } else if (rowNumber < 1000) {
        grid.getColumn("#").setWidth(95);
    } else {
        grid.getColumn("#").setWidth(115);
    }

    if (!showRowNumbers) {
        grid.getColumn("#").setHidden(true);
    } else {
        grid.setFrozenColumnCount(1);
    }

    return grid;
}

From source file:org.apache.oozie.command.SchemaCheckXCommand.java

private String getSQLTypeFromInt(int t) {
    switch (t) {/*from   www . jav  a2  s  . c o m*/
    case Types.BIT:
        return "BIT";
    case Types.TINYINT:
        return "TINYINT";
    case Types.SMALLINT:
        return "SMALLINT";
    case Types.INTEGER:
        return "INTEGER";
    case Types.BIGINT:
        return "BIGINT";
    case Types.FLOAT:
        return "FLOAT";
    case Types.REAL:
        return "REAL";
    case Types.DOUBLE:
        return "DOUBLE";
    case Types.NUMERIC:
        return "NUMERIC";
    case Types.DECIMAL:
        return "DECIMAL";
    case Types.CHAR:
        return "CHAR";
    case Types.VARCHAR:
        return "VARCHAR";
    case Types.LONGVARCHAR:
        return "LONGVARCHAR";
    case Types.DATE:
        return "DATE";
    case Types.TIME:
        return "TIME";
    case Types.TIMESTAMP:
        return "TIMESTAMP";
    case Types.BINARY:
        return "BINARY";
    case Types.VARBINARY:
        return "VARBINARY";
    case Types.LONGVARBINARY:
        return "LONGVARBINARY";
    case Types.NULL:
        return "NULL";
    case Types.OTHER:
        return "OTHER";
    case Types.JAVA_OBJECT:
        return "JAVA_OBJECT";
    case Types.DISTINCT:
        return "DISTINCT";
    case Types.STRUCT:
        return "STRUCT";
    case Types.ARRAY:
        return "ARRAY";
    case Types.BLOB:
        return "BLOB";
    case Types.CLOB:
        return "CLOB";
    case Types.REF:
        return "REF";
    case Types.DATALINK:
        return "DATALINK";
    case Types.BOOLEAN:
        return "BOOLEAN";
    case Types.ROWID:
        return "ROWID";
    case Types.NCHAR:
        return "NCHAR";
    case Types.NVARCHAR:
        return "NVARCHAR";
    case Types.LONGNVARCHAR:
        return "LONGNVARCHAR";
    case Types.NCLOB:
        return "NCLOB";
    case Types.SQLXML:
        return "SQLXML";
    default:
        return "unknown";
    }
}

From source file:org.executequery.gui.importexport.AbstractImportExportWorker.java

/**
 * Sets the specified value in the specified position for the
 * specified java.sql.Type within the prepared statement.
 *
 * @param value - the value/*from   w w w.  ja v a2s .c  o  m*/
 * @param index - the position within the statement
 * @param sqlType - the SQL type
 * @param trim - whether to trim the whitespace from the value
 * @param df - the DataFormat object for date values
 */
protected void setValue(String value, int index, int sqlType, boolean trim, DateFormat df) throws Exception {

    if (value == null) {

        prepStmnt.setNull(index, sqlType);

    } else {

        switch (sqlType) {

        case Types.TINYINT:
            byte _byte = Byte.valueOf(value).byteValue();
            prepStmnt.setShort(index, _byte);
            break;

        case Types.BIGINT:
            long _long = Long.valueOf(value).longValue();
            prepStmnt.setLong(index, _long);
            break;

        case Types.SMALLINT:
            short _short = Short.valueOf(value).shortValue();
            prepStmnt.setShort(index, _short);
            break;

        case Types.LONGVARCHAR:
        case Types.CHAR:
        case Types.VARCHAR:
            if (trim) {
                value = value.trim();
            }
            prepStmnt.setString(index, value);
            break;

        case Types.BIT:
        case Types.BOOLEAN:

            String booleanValue = value;
            if ("t".equalsIgnoreCase(value)) {

                booleanValue = "true";

            } else if ("f".equalsIgnoreCase(value)) {

                booleanValue = "false";
            }

            boolean _boolean = Boolean.valueOf(booleanValue).booleanValue();
            prepStmnt.setBoolean(index, _boolean);
            break;

        case Types.NUMERIC:
        case Types.DECIMAL:
            prepStmnt.setBigDecimal(index, new BigDecimal(value));
            break;

        case Types.REAL:
            float _float = Float.valueOf(value).floatValue();
            prepStmnt.setFloat(index, _float);
            break;

        case Types.FLOAT:
        case Types.DOUBLE:
            prepStmnt.setDouble(index, Double.parseDouble(value));
            break;

        case Types.INTEGER:
            prepStmnt.setInt(index, Integer.parseInt(value));
            break;

        case Types.DATE:
        case Types.TIME:
        case Types.TIMESTAMP:
            // if the date format is null, insert as a char value
            if (df != null) {
                java.util.Date j_datetime = df.parse(value);
                prepStmnt.setDate(index, new java.sql.Date(j_datetime.getTime()));
            } else {
                try {
                    prepStmnt.setObject(index, value, sqlType);
                    /*
                    if (sqlType == Types.TIMESTAMP) {
                        prepStmnt.setTimestamp(index,
                                java.sql.Timestamp.valueOf(value));
                    }
                    else if (sqlType == Types.TIME) {
                        prepStmnt.setTime(index,
                                java.sql.Time.valueOf(value));
                    }
                    else {
                        prepStmnt.setDate(index,
                                java.sql.Date.valueOf(value));
                    }
                     */
                }
                // want a more useful message here than what will likely
                // be returned due to internal driver code on formatting
                // a SQL date value from string
                // (ie. could be parsing error, number format etc...)
                catch (Exception e) {
                    throw new IllegalArgumentException("[ " + MiscUtils.getExceptionName(e) + " ] "
                            + getBundle().getString("AbstractImportExportWorker.dateConversionError"));
                }

            }
            break;

        case Types.LONGVARBINARY:
        case Types.BINARY:
        case Types.BLOB:
        case Types.CLOB:
            prepStmnt.setBytes(index, Base64.decode(value));
            break;

        default:
            prepStmnt.setObject(index, value);
            break;
        }
    }
}

From source file:com.mapd.utility.SQLImporter.java

private String getColType(int cType, int precision, int scale) {
    if (precision > 19) {
        precision = 19;//from w w  w.  ja  va  2  s.co  m
    }
    if (scale > 19) {
        scale = 18;
    }
    switch (cType) {
    case java.sql.Types.TINYINT:
    case java.sql.Types.SMALLINT:
        return ("SMALLINT");
    case java.sql.Types.INTEGER:
        return ("INTEGER");
    case java.sql.Types.BIGINT:
        return ("BIGINT");
    case java.sql.Types.FLOAT:
        return ("FLOAT");
    case java.sql.Types.DECIMAL:
        return ("DECIMAL(" + precision + "," + scale + ")");
    case java.sql.Types.DOUBLE:
        return ("DOUBLE");
    case java.sql.Types.REAL:
        return ("REAL");
    case java.sql.Types.NUMERIC:
        return ("NUMERIC(" + precision + "," + scale + ")");
    case java.sql.Types.TIME:
        return ("TIME");
    case java.sql.Types.TIMESTAMP:
        return ("TIMESTAMP");
    case java.sql.Types.DATE:
        return ("DATE");
    case java.sql.Types.BOOLEAN:
    case java.sql.Types.BIT: // deal with postgress treating boolean as bit... this will bite me
        return ("BOOLEAN");
    case java.sql.Types.NVARCHAR:
    case java.sql.Types.VARCHAR:
    case java.sql.Types.NCHAR:
    case java.sql.Types.CHAR:
    case java.sql.Types.LONGVARCHAR:
    case java.sql.Types.LONGNVARCHAR:
        return ("TEXT ENCODING DICT");
    default:
        throw new AssertionError("Column type " + cType + " not Supported");
    }
}

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

/**
 * Get one value into DbValue from ResultSet
 * //  w  w  w  .j  ava2 s  . c o  m
 * @param rs
 * @param value
 * @throws WaarpDatabaseSqlException
 */
static public void getTrueValue(ResultSet rs, DbValue value) throws WaarpDatabaseSqlException {
    try {
        switch (value.type) {
        case Types.VARCHAR:
            value.value = rs.getString(value.column);
            break;
        case Types.LONGVARCHAR:
            value.value = rs.getString(value.column);
            break;
        case Types.BIT:
            value.value = rs.getBoolean(value.column);
            break;
        case Types.TINYINT:
            value.value = rs.getByte(value.column);
            break;
        case Types.SMALLINT:
            value.value = rs.getShort(value.column);
            break;
        case Types.INTEGER:
            value.value = rs.getInt(value.column);
            break;
        case Types.BIGINT:
            value.value = rs.getLong(value.column);
            break;
        case Types.REAL:
            value.value = rs.getFloat(value.column);
            break;
        case Types.DOUBLE:
            value.value = rs.getDouble(value.column);
            break;
        case Types.VARBINARY:
            value.value = rs.getBytes(value.column);
            break;
        case Types.DATE:
            value.value = rs.getDate(value.column);
            break;
        case Types.TIMESTAMP:
            value.value = rs.getTimestamp(value.column);
            break;
        case Types.CLOB:
            value.value = rs.getClob(value.column).getCharacterStream();
            break;
        case Types.BLOB:
            value.value = rs.getBlob(value.column).getBinaryStream();
            break;
        default:
            throw new WaarpDatabaseSqlException("Type not supported: " + value.type + " for " + value.column);
        }
    } catch (SQLException e) {
        DbSession.error(e);
        throw new WaarpDatabaseSqlException("Getting values in error: " + value.type + " for " + value.column,
                e);
    }
}

From source file:com.squid.core.domain.operators.ExtendedType.java

public static IDomain computeDomain(int data_type, int size, int scale) {
    switch (data_type) {
    case Types.BOOLEAN:
    case Types.BIT:// on PG systems, this is how a boolean is actually represented by the driver
        return IDomain.BOOLEAN;
    case Types.TINYINT:
    case Types.BIGINT:
    case Types.INTEGER:
    case Types.SMALLINT:
        return IDomain.NUMERIC;
    ///////////////////////////
    case Types.REAL:
    case Types.DOUBLE:
    case Types.FLOAT:
        return IDomain.CONTINUOUS;
    case Types.NUMERIC:
    case Types.DECIMAL:
        return scale > 0 || size == 0 ? IDomain.CONTINUOUS : IDomain.NUMERIC;
    case Types.CHAR:
    case Types.NCHAR:
    case Types.VARCHAR:
    case Types.NVARCHAR:
    case Types.LONGVARCHAR:
    case Types.CLOB:
        return IDomain.STRING;
    ///////////////////////////
    case Types.TIME:
        return IDomain.TIME;
    case Types.DATE:
        return IDomain.DATE;
    case Types.TIMESTAMP:
        return IDomain.TIMESTAMP;
    ///////////////////////////
    default:/*from ww w  .  j ava 2  s. com*/
        return IDomain.UNKNOWN;
    }
}

From source file:org.eclipse.ecr.core.storage.sql.extensions.H2Fulltext.java

protected static String asString(Object data, int type) throws SQLException {
    if (data == null) {
        return "";
    }// ww  w . j  av a 2  s .c o m
    switch (type) {
    case Types.BIT:
    case DataType.TYPE_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 Message.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 DataType.TYPE_DATALINK:
    case Types.DISTINCT:
        throw new SQLException("Unsupported column data type: " + type);
    default:
        return "";
    }
}

From source file:org.sakaiproject.webservices.SakaiReport.java

private String getColumnValue(ResultSet rs, int colType, int colIndex) throws SQLException, IOException {
    String value = "";
    switch (colType) {
    case Types.BIT:
    case Types.JAVA_OBJECT:
        value = handleObject(rs.getObject(colIndex));
        break;/*w  w w  . j a  va2s  . c  o m*/
    case Types.BOOLEAN:
        boolean b = rs.getBoolean(colIndex);
        value = Boolean.valueOf(b).toString();
        break;
    case NCLOB: // todo : use rs.getNClob
    case Types.CLOB:
        Clob c = rs.getClob(colIndex);
        if (c != null) {
            value = read(c);
        }
        break;
    case Types.BIGINT:
        value = handleLong(rs, colIndex);
        break;
    case Types.DECIMAL:
    case Types.DOUBLE:
    case Types.FLOAT:
    case Types.REAL:
    case Types.NUMERIC:
        value = handleBigDecimal(rs.getBigDecimal(colIndex));
        break;
    case Types.INTEGER:
    case Types.TINYINT:
    case Types.SMALLINT:
        value = handleInteger(rs, colIndex);
        break;
    case Types.DATE:
        value = handleDate(rs, colIndex);
        break;
    case Types.TIME:
        value = handleTime(rs.getTime(colIndex));
        break;
    case Types.TIMESTAMP:
        value = handleTimestamp(rs.getTimestamp(colIndex));
        break;
    case NVARCHAR: // todo : use rs.getNString
    case NCHAR: // todo : use rs.getNString
    case LONGNVARCHAR: // todo : use rs.getNString
    case Types.LONGVARCHAR:
    case Types.VARCHAR:
    case Types.CHAR:
        value = rs.getString(colIndex);
        break;
    case Types.VARBINARY:
    case Types.BINARY:
        value = handleRaw(rs.getBytes(colIndex));
        break;
    default:
        value = "";
    }

    if (value == null) {
        value = "";
    }

    return value;

}

From source file:org.apache.cassandra.cql.jdbc.HandleObjects.java

public static final ByteBuffer makeBytes(Object object, int baseType, int scaleOrLength) throws SQLException {
    Class<? extends Object> objectClass = object.getClass();
    boolean isCollection = (Collection.class.isAssignableFrom(objectClass));
    int targetSqlType = isCollection ? Types.OTHER : baseType;
    // Type check first
    switch (targetSqlType) {
    case Types.TINYINT:
        // Only Numeric classes, Strings and Booleans are supported for transformation to TINYINT
        if (!(objectClass == String.class || objectClass == Boolean.class
                || Number.class.isAssignableFrom(object.getClass())))
            throw makeBadMapping(objectClass, STR_BOOL_NUMERIC, "TINYINT");
        break;//from www  .  j  av  a  2s  .c o m

    case Types.SMALLINT:
        // Only Numeric classes, Strings and Booleans are supported for transformation to SMALLINT
        if (!(objectClass == String.class || objectClass == Boolean.class
                || Number.class.isAssignableFrom(object.getClass())))
            throw makeBadMapping(objectClass, STR_BOOL_NUMERIC, "SMALLINT");
        break;

    case Types.INTEGER:
        // Only Numeric classes, Strings and Booleans are supported for transformation to INTEGER
        if (!(objectClass == String.class || objectClass == Boolean.class
                || Number.class.isAssignableFrom(object.getClass())))
            throw makeBadMapping(objectClass, STR_BOOL_NUMERIC, "INTEGER");
        break;

    case Types.BIGINT:
        // Only Numeric classes, Strings and Booleans are supported for transformation to BIGINT
        if (!(objectClass == String.class || objectClass == Boolean.class
                || Number.class.isAssignableFrom(object.getClass())))
            throw makeBadMapping(objectClass, STR_BOOL_NUMERIC, "BIGINT");
        break;

    case Types.REAL:
    case Types.FLOAT:
    case Types.DOUBLE:
    case Types.DECIMAL:
        // Only Numeric classes Strings and Booleans are supported for transformation to REAL,FLOAT,DOUBLE,DECIMAL
        if (!(objectClass == String.class || objectClass == Boolean.class
                || Number.class.isAssignableFrom(object.getClass())))
            throw makeBadMapping(objectClass, STR_BOOL_NUMERIC, "the floating point types");
        break;

    case Types.NUMERIC:
        //NB This as a special case variation for Cassandra!! NUMERIC is transformed to java BigInteger (varint CQL type)
        //
        // Only Numeric classes Strings and Booleans are supported for transformation to NUMERIC
        if (!(objectClass == String.class || objectClass == Boolean.class
                || Number.class.isAssignableFrom(object.getClass())))
            throw makeBadMapping(objectClass, STR_BOOL_NUMERIC, "NUMERIC");
        break;

    case Types.BIT:
        // Only Numeric classes Strings and Booleans are supported for transformation to BIT
        if (!(objectClass == String.class || objectClass == Boolean.class
                || Number.class.isAssignableFrom(object.getClass())))
            throw makeBadMapping(objectClass, STR_BOOL_NUMERIC, "BIT");
        break;

    case Types.BOOLEAN:
        // Only Numeric classes Strings and Booleans are supported for transformation to BOOLEAN
        if (!(objectClass == String.class || objectClass == Boolean.class
                || Number.class.isAssignableFrom(object.getClass())))
            throw makeBadMapping(objectClass, STR_BOOL_NUMERIC, "BOOLEAN");
        break;

    case Types.CHAR:
    case Types.VARCHAR:
    case Types.LONGVARCHAR:
    case Types.NVARCHAR:
    case Types.LONGNVARCHAR:
        if (!objectClass.isAssignableFrom(String.class))
            throw makeBadMapping(objectClass, "String", "the various VARCHAR types");
        break;

    case Types.BINARY:
    case Types.VARBINARY:
    case Types.LONGVARBINARY:
        if (!(objectClass.isAssignableFrom(ByteBuffer.class) || objectClass.getSimpleName().equals("byte[]")))
            throw makeBadMapping(objectClass, "ByteBuffer or byte[]", "the BINARY Types");
        break;

    case Types.DATE:
        if (!(objectClass == String.class || objectClass == java.util.Date.class || objectClass == Date.class
                || objectClass == Timestamp.class))
            throw makeBadMapping(objectClass, "String, Date(java and sql) or Timestamp types", "DATE");
        break;

    case Types.TIME:
        if (!(objectClass == String.class || objectClass == java.util.Date.class || objectClass == Time.class
                || objectClass == Timestamp.class))
            throw makeBadMapping(objectClass, "String, Date (java), Time or Timestamp types", "TIME");
        break;

    case Types.TIMESTAMP:
        if (!(objectClass == String.class || objectClass == java.util.Date.class || objectClass == Date.class
                || objectClass == Timestamp.class))
            throw makeBadMapping(objectClass, "String, Date(java and sql) or Timestamp types", "TIMESTAMP");
        break;

    case Types.DATALINK:
        if (objectClass != URL.class)
            throw makeBadMapping(objectClass, "a URL type", "DATALINK");
        break;

    case Types.JAVA_OBJECT:
        break;

    case Types.OTHER:
        // Only Collection classes for transformation to OTHER
        if (!(List.class.isAssignableFrom(object.getClass()) || Set.class.isAssignableFrom(object.getClass())
                || Map.class.isAssignableFrom(object.getClass())))
            throw makeBadMapping(objectClass, STR_BOOL_NUMERIC, "OTHER");
        break;

    case Types.ROWID:
        if (objectClass != RowId.class)
            throw makeBadMapping(objectClass, "a RowId type", "ROWID");
        break;

    default:
        throw new SQLNonTransientException("Unsupported transformation to Jdbc Type: " + targetSqlType);
    }

    // see if we can map to an supported Type
    switch (targetSqlType) {
    case Types.BIT:
        BigInteger bitvalue = objectToBITorTINYINTorSMALLINTorNUMERIC(objectClass, object);
        assert bitvalue != null;
        return JdbcInteger.instance.decompose((bitvalue == BigInteger.ZERO) ? BigInteger.ZERO : BigInteger.ONE);

    case Types.TINYINT:
    case Types.SMALLINT:
    case Types.NUMERIC:
        BigInteger varint = objectToBITorTINYINTorSMALLINTorNUMERIC(objectClass, object);
        assert varint != null;
        return JdbcInteger.instance.decompose(varint);

    case Types.INTEGER:
        Integer value = objectToINTEGER(objectClass, object);
        assert value != null;
        return JdbcInt32.instance.decompose(value);

    case Types.BIGINT:
        Long longvalue = objectToBIGINT(objectClass, object);
        assert longvalue != null;
        return JdbcLong.instance.decompose(longvalue);

    case Types.BOOLEAN:
        Boolean bool = objectToBOOLEAN(objectClass, object);
        assert bool != null;
        return JdbcBoolean.instance.decompose(bool);

    case Types.CHAR:
    case Types.VARCHAR:
    case Types.LONGVARCHAR:
    case Types.NVARCHAR:
    case Types.LONGNVARCHAR:
        return ByteBufferUtil.bytes((String) object);

    case Types.BINARY:
    case Types.VARBINARY:
    case Types.LONGVARBINARY:
        if (objectClass.isAssignableFrom(ByteBuffer.class)) {
            return ((ByteBuffer) object);
        } else if (objectClass.getSimpleName().equals("byte[]")) {
            return ByteBuffer.wrap((byte[]) object);
        } else
            return null; // this should not happen

    case Types.DATE:
    case Types.TIME:
    case Types.TIMESTAMP:
        Long millis = objectToDATEorTIMEorTIMESTAMP(objectClass, object);
        assert millis != null;
        return JdbcLong.instance.decompose(millis);

    case Types.DATALINK:
        String urlAsString = ((URL) object).toExternalForm();
        return JdbcUTF8.instance.decompose(urlAsString);

    case Types.JAVA_OBJECT:
        return javaObject(object);

    case Types.OTHER:
        if (List.class.isAssignableFrom(objectClass)) {
            return handleAsList(objectClass, object);
        } else if (Set.class.isAssignableFrom(objectClass)) {
            return handleAsSet(objectClass, object);
        } else if (Map.class.isAssignableFrom(objectClass)) {
            return handleAsMap(objectClass, object);
        } else
            return null;

    case Types.ROWID:
        byte[] bytes = ((RowId) object).getBytes();
        return ByteBuffer.wrap(bytes);

    default:
        LOG.warn("Unhandled JDBC type: " + targetSqlType);
        return null;
    }
}