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:org.jumpmind.symmetric.db.AbstractTriggerTemplate.java

protected String buildKeyVariablesDeclare(Column[] columns, String prefix) {
    String text = "";
    for (int i = 0; i < columns.length; i++) {
        text += "declare @" + prefix + "pk" + i + " ";
        switch (columns[i].getMappedTypeCode()) {
        case Types.TINYINT:
        case Types.SMALLINT:
        case Types.INTEGER:
        case Types.BIGINT:
            text += "bigint\n";
            break;
        case Types.NUMERIC:
        case Types.DECIMAL:
            text += "decimal\n";
            break;
        case Types.FLOAT:
        case Types.REAL:
        case Types.DOUBLE:
            text += "float\n";
            break;
        case Types.CHAR:
        case Types.VARCHAR:
        case ColumnTypes.NVARCHAR:
        case ColumnTypes.LONGNVARCHAR:
        case Types.LONGVARCHAR:
            text += "varchar(1000)\n";
            break;
        case Types.DATE:
            text += "date\n";
            break;
        case Types.TIME:
            text += "time\n";
            break;
        case Types.TIMESTAMP:
            text += "datetime\n";
            break;
        case Types.BOOLEAN:
        case Types.BIT:
            text += "bit\n";
            break;
        case Types.CLOB:
            text += "varchar(max)\n";
            break;
        case Types.BLOB:
        case Types.BINARY:
        case Types.VARBINARY:
        case Types.LONGVARBINARY:
        case -10: // SQL-Server ntext binary type
            text += "varbinary(max)\n";
            break;
        case Types.OTHER:
            text += "varbinary(max)\n";
            break;
        default:/*from  w w w . j  a  v  a2  s .c  o  m*/
            if (columns[i].getJdbcTypeName() != null
                    && columns[i].getJdbcTypeName().equalsIgnoreCase("interval")) {
                text += "interval";
                break;
            }
            throw new NotImplementedException(columns[i] + " is of type " + columns[i].getMappedType());
        }
    }

    return text;
}

From source file:com.mirth.connect.donkey.test.util.TestUtils.java

private static String typeToString(int sqlType) {
    switch (sqlType) {
    case Types.ARRAY:
        return "ARRAY";
    case Types.BIGINT:
        return "BIGINT";
    case Types.BINARY:
        return "BINARY";
    case Types.BIT:
        return "BIT";
    case Types.BLOB:
        return "BLOB";
    case Types.BOOLEAN:
        return "BOOLEAN";
    case Types.CHAR:
        return "CHAR";
    case Types.CLOB:
        return "CLOB";
    case Types.DATALINK:
        return "DATALINK";
    case Types.DATE:
        return "DATE";
    case Types.DECIMAL:
        return "DECIMAL";
    case Types.DISTINCT:
        return "DISTINCT";
    case Types.DOUBLE:
        return "DOUBLE";
    case Types.FLOAT:
        return "FLOAT";
    case Types.INTEGER:
        return "INTEGER";
    case Types.JAVA_OBJECT:
        return "JAVA_OBJECT";
    case Types.LONGNVARCHAR:
        return "LONGNVARCHAR";
    case Types.LONGVARBINARY:
        return "LONGVARBINARY";
    case Types.LONGVARCHAR:
        return "LONGVARCHAR";
    case Types.NCHAR:
        return "NCHAR";
    case Types.NCLOB:
        return "NCLOB";
    case Types.NULL:
        return "NULL";
    case Types.NUMERIC:
        return "NUMERIC";
    case Types.NVARCHAR:
        return "NVARCHAR";
    case Types.OTHER:
        return "OTHER";
    case Types.REAL:
        return "REAL";
    case Types.REF:
        return "REF";
    case Types.ROWID:
        return "ROWID";
    case Types.SMALLINT:
        return "SMALLINT";
    case Types.SQLXML:
        return "SQLXML";
    case Types.STRUCT:
        return "STRUCT";
    case Types.TIME:
        return "TIME";
    case Types.TIMESTAMP:
        return "TIMESTAMP";
    case Types.TINYINT:
        return "TINYINT";
    case Types.VARBINARY:
        return "VARBINARY";
    case Types.VARCHAR:
        return "VARCHAR";
    default://from   w w  w . ja  v  a 2s  .  co m
        return "UNKNOWN";
    }
}

From source file:org.acmsl.queryj.metadata.engines.JdbcTypeManager.java

/**
 * {@inheritDoc}//from ww w  .j a va 2s  .c o m
 */
@NotNull
@Override
public List<Integer> getCompatibleTypesFor(final int type) {
    @NotNull
    final List<Integer> result = new ArrayList<>();

    switch (type) {
    case Types.CHAR:
    case Types.LONGNVARCHAR:
    case Types.LONGVARCHAR:
    case Types.NCHAR:
    case Types.NVARCHAR:
    case Types.VARCHAR:
        result.add(Types.CHAR);
        result.add(Types.LONGNVARCHAR);
        result.add(Types.LONGVARCHAR);
        result.add(Types.NCHAR);
        result.add(Types.NVARCHAR);
        result.add(Types.VARCHAR);
        break;
    case Types.NUMERIC:
    case Types.BIGINT:
    case Types.BIT:
    case Types.BOOLEAN:
    case Types.DECIMAL:
    case Types.DOUBLE:
    case Types.FLOAT:
    case Types.INTEGER:
    case Types.REAL:
    case Types.SMALLINT:
    case Types.TINYINT:
        result.add(Types.NUMERIC);
        result.add(Types.BIGINT);
        result.add(Types.BIT);
        result.add(Types.BOOLEAN);
        result.add(Types.DECIMAL);
        result.add(Types.DOUBLE);
        result.add(Types.FLOAT);
        result.add(Types.INTEGER);
        result.add(Types.REAL);
        result.add(Types.SMALLINT);
        result.add(Types.TINYINT);
        break;
    default:
        break;
    }

    return result;
}

From source file:org.apache.sqoop.mapreduce.hcat.SqoopHCatUtilities.java

public static String sqlTypeString(int sqlType) {
    switch (sqlType) {
    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:/*from   w  w  w. jav  a 2  s.c  o m*/
        return "<UNKNOWN>";
    }
}

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

private ODataDataType getODataDataType(int columnType) {
    ODataDataType dataType;/*w  ww  .  ja  va  2  s. c o  m*/
    switch (columnType) {
    case Types.INTEGER:
        dataType = ODataDataType.INT32;
        break;
    case Types.TINYINT:
        /* fall through */
    case Types.SMALLINT:
        dataType = ODataDataType.INT16;
        break;
    case Types.DOUBLE:
        dataType = ODataDataType.DOUBLE;
        break;
    case Types.VARCHAR:
        /* fall through */
    case Types.CHAR:
        /* fall through */
    case Types.LONGVARCHAR:
        /* fall through */
    case Types.CLOB:
        /* fall through */
    case Types.LONGNVARCHAR:
        /* fall through */
    case Types.NCHAR:
        /* fall through */
    case Types.NVARCHAR:
        /* fall through */
    case Types.NCLOB:
        /* fall through */
    case Types.SQLXML:
        dataType = ODataDataType.STRING;
        break;
    case Types.BOOLEAN:
        /* fall through */
    case Types.BIT:
        dataType = ODataDataType.BOOLEAN;
        break;
    case Types.BLOB:
        /* fall through */
    case Types.BINARY:
        /* fall through */
    case Types.LONGVARBINARY:
        /* fall through */
    case Types.VARBINARY:
        dataType = ODataDataType.BINARY;
        break;
    case Types.DATE:
        dataType = ODataDataType.DATE;
        break;
    case Types.DECIMAL:
        /* fall through */
    case Types.NUMERIC:
        dataType = ODataDataType.DECIMAL;
        break;
    case Types.FLOAT:
        /* fall through */
    case Types.REAL:
        dataType = ODataDataType.SINGLE;
        break;
    case Types.TIME:
        dataType = ODataDataType.TIMEOFDAY;
        break;
    case Types.BIGINT:
        dataType = ODataDataType.INT64;
        break;
    case Types.TIMESTAMP:
        dataType = ODataDataType.DATE_TIMEOFFSET;
        break;
    default:
        dataType = ODataDataType.STRING;
        break;
    }
    return dataType;
}

From source file:com.feedzai.commons.sql.abstraction.engine.AbstractDatabaseEngine.java

/**
 * Maps the database type to {@link DbColumnType}. If there's no mapping a {@link DbColumnType#UNMAPPED} is returned.
 *
 * @param type The SQL type from {@link java.sql.Types}.
 * @return The {@link DbColumnType}./*w w w .  j  a  v  a2  s.c  o m*/
 */
protected DbColumnType toPdbType(final int type) {
    switch (type) {
    case Types.ARRAY:
        return DbColumnType.UNMAPPED;
    case Types.BIGINT:
        return DbColumnType.LONG;
    case Types.BINARY:
        return DbColumnType.BLOB;
    case Types.BIT:
        return DbColumnType.BOOLEAN;
    case Types.BLOB:
        return DbColumnType.BLOB;
    case Types.BOOLEAN:
        return DbColumnType.BOOLEAN;
    case Types.CHAR:
        return DbColumnType.STRING;
    case Types.CLOB:
        return DbColumnType.STRING;
    case Types.DATALINK:
        return DbColumnType.UNMAPPED;
    case Types.DATE:
        return DbColumnType.UNMAPPED;
    case Types.DECIMAL:
        return DbColumnType.DOUBLE;
    case Types.DISTINCT:
        return DbColumnType.UNMAPPED;
    case Types.DOUBLE:
        return DbColumnType.DOUBLE;
    case Types.FLOAT:
        return DbColumnType.DOUBLE;
    case Types.INTEGER:
        return DbColumnType.INT;
    case Types.JAVA_OBJECT:
        return DbColumnType.BLOB;
    case Types.LONGNVARCHAR:
        return DbColumnType.STRING;
    case Types.LONGVARBINARY:
        return DbColumnType.BLOB;
    case Types.LONGVARCHAR:
        return DbColumnType.STRING;
    case Types.NCHAR:
        return DbColumnType.STRING;
    case Types.NCLOB:
        return DbColumnType.STRING;
    case Types.NULL:
        return DbColumnType.UNMAPPED;
    case Types.NUMERIC:
        return DbColumnType.DOUBLE;
    case Types.NVARCHAR:
        return DbColumnType.STRING;
    case Types.OTHER:
        return DbColumnType.UNMAPPED;
    case Types.REAL:
        return DbColumnType.DOUBLE;
    case Types.REF:
        return DbColumnType.UNMAPPED;
    case Types.ROWID:
        return DbColumnType.STRING;
    case Types.SMALLINT:
        return DbColumnType.INT;
    case Types.SQLXML:
        return DbColumnType.STRING;
    case Types.STRUCT:
        return DbColumnType.UNMAPPED;
    case Types.TIME:
        return DbColumnType.UNMAPPED;
    case Types.TIMESTAMP:
        return DbColumnType.LONG;
    case Types.TINYINT:
        return DbColumnType.INT;
    case Types.VARBINARY:
        return DbColumnType.BLOB;
    case Types.VARCHAR:
        return DbColumnType.STRING;
    default:
        return DbColumnType.UNMAPPED;
    }
}

From source file:helma.objectmodel.db.NodeManager.java

/**
 *  Create a new Node from a ResultSet./* w w w  . j  a  v  a  2  s. c  om*/
 */
public Node createNode(DbMapping dbm, ResultSet rs, DbColumn[] columns, int offset)
        throws SQLException, IOException, ClassNotFoundException {
    HashMap propBuffer = new HashMap();
    String id = null;
    String name = null;
    String protoName = dbm.getTypeName();
    DbMapping dbmap = dbm;

    Node node = new Node(safe);

    for (int i = 0; i < columns.length; i++) {

        int columnNumber = i + 1 + offset;

        // set prototype?
        if (columns[i].isPrototypeField()) {
            String protoId = rs.getString(columnNumber);
            protoName = dbm.getPrototypeName(protoId);

            if (protoName != null) {
                dbmap = getDbMapping(protoName);

                if (dbmap == null) {
                    // invalid prototype name!
                    app.logError("No prototype defined for prototype mapping \"" + protoName
                            + "\" - Using default prototype \"" + dbm.getTypeName() + "\".");
                    dbmap = dbm;
                    protoName = dbmap.getTypeName();
                }
            }
        }

        // set id?
        if (columns[i].isIdField()) {
            id = rs.getString(columnNumber);
            // if id == null, the object doesn't actually exist - return null
            if (id == null) {
                return null;
            }
        }

        // set name?
        if (columns[i].isNameField()) {
            name = rs.getString(columnNumber);
        }

        Property newprop = new Property(node);

        switch (columns[i].getType()) {
        case Types.BIT:
        case Types.BOOLEAN:
            newprop.setBooleanValue(rs.getBoolean(columnNumber));

            break;

        case Types.TINYINT:
        case Types.BIGINT:
        case Types.SMALLINT:
        case Types.INTEGER:
            newprop.setIntegerValue(rs.getLong(columnNumber));

            break;

        case Types.REAL:
        case Types.FLOAT:
        case Types.DOUBLE:
            newprop.setFloatValue(rs.getDouble(columnNumber));

            break;

        case Types.DECIMAL:
        case Types.NUMERIC:

            BigDecimal num = rs.getBigDecimal(columnNumber);
            if (num == null) {
                break;
            }
            if (num.scale() > 0) {
                newprop.setFloatValue(num.doubleValue());
            } else {
                newprop.setIntegerValue(num.longValue());
            }

            break;

        case Types.VARBINARY:
        case Types.BINARY:
            newprop.setJavaObjectValue(rs.getBytes(columnNumber));

            break;

        case Types.BLOB:
        case Types.LONGVARBINARY: {
            InputStream in = rs.getBinaryStream(columnNumber);
            if (in == null) {
                break;
            }
            ByteArrayOutputStream bout = new ByteArrayOutputStream();
            byte[] buffer = new byte[2048];
            int read;
            while ((read = in.read(buffer)) > -1) {
                bout.write(buffer, 0, read);
            }
            newprop.setJavaObjectValue(bout.toByteArray());
        }

            break;

        case Types.LONGVARCHAR:
            try {
                newprop.setStringValue(rs.getString(columnNumber));
            } catch (SQLException x) {
                Reader in = rs.getCharacterStream(columnNumber);
                if (in == null) {
                    newprop.setStringValue(null);
                    break;
                }
                StringBuffer out = new StringBuffer();
                char[] buffer = new char[2048];
                int read;
                while ((read = in.read(buffer)) > -1) {
                    out.append(buffer, 0, read);
                }
                newprop.setStringValue(out.toString());
            }

            break;

        case Types.CHAR:
        case Types.VARCHAR:
        case Types.OTHER:
            newprop.setStringValue(rs.getString(columnNumber));

            break;

        case Types.DATE:
        case Types.TIME:
        case Types.TIMESTAMP:
            newprop.setDateValue(rs.getTimestamp(columnNumber));

            break;

        case Types.NULL:
            newprop.setStringValue(null);

            break;

        case Types.CLOB:
            Clob cl = rs.getClob(columnNumber);
            if (cl == null) {
                newprop.setStringValue(null);
                break;
            }
            char[] c = new char[(int) cl.length()];
            Reader isr = cl.getCharacterStream();
            isr.read(c);
            newprop.setStringValue(String.copyValueOf(c));
            break;

        default:
            newprop.setStringValue(rs.getString(columnNumber));

            break;
        }

        if (rs.wasNull()) {
            newprop.setStringValue(null);
        }

        propBuffer.put(columns[i].getName(), newprop);

        // mark property as clean, since it's fresh from the db
        newprop.dirty = false;
    }

    if (id == null) {
        return null;
    } else {
        Transactor tx = Transactor.getInstance();
        if (tx != null) {
            // Check if the node is already registered with the transactor -
            // it may be in the process of being DELETED, but do return the
            // new node if the old one has been marked as INVALID.
            DbKey key = new DbKey(dbmap, id);
            Node dirtyNode = tx.getDirtyNode(key);
            if (dirtyNode != null && dirtyNode.getState() != Node.INVALID) {
                return dirtyNode;
            }
        }
    }

    Hashtable propMap = new Hashtable();
    DbColumn[] columns2 = dbmap.getColumns();
    for (int i = 0; i < columns2.length; i++) {
        Relation rel = columns2[i].getRelation();
        if (rel != null && rel.isPrimitiveOrReference()) {
            Property prop = (Property) propBuffer.get(columns2[i].getName());

            if (prop == null) {
                continue;
            }

            prop.setName(rel.propName);

            // if the property is a pointer to another node, change the property type to NODE
            if (rel.isReference() && rel.usesPrimaryKey()) {
                // FIXME: References to anything other than the primary key are not supported
                prop.convertToNodeReference(rel);
            }
            propMap.put(rel.propName, prop);
        }
    }

    node.init(dbmap, id, name, protoName, propMap);
    return node;
}

From source file:org.apache.openjpa.jdbc.sql.DBDictionary.java

/**
 * Return the preferred {@link Types} constant for the given
 * {@link JavaTypes} or {@link JavaSQLTypes} constant.
 */// w  ww . jav a  2  s  . com
public int getJDBCType(int metaTypeCode, boolean lob, int precis, int scale) {
    if (lob) {
        switch (metaTypeCode) {
        case JavaTypes.STRING:
        case JavaSQLTypes.ASCII_STREAM:
        case JavaSQLTypes.CHAR_STREAM:
            return getPreferredType(Types.CLOB);
        default:
            return getPreferredType(Types.BLOB);
        }
    }

    switch (metaTypeCode) {
    case JavaTypes.BOOLEAN:
    case JavaTypes.BOOLEAN_OBJ:
        return getPreferredType(Types.BIT);
    case JavaTypes.BYTE:
    case JavaTypes.BYTE_OBJ:
        return getPreferredType(Types.TINYINT);
    case JavaTypes.CHAR:
    case JavaTypes.CHAR_OBJ:
        if (storeCharsAsNumbers)
            return getPreferredType(Types.INTEGER);
        return getPreferredType(Types.CHAR);
    case JavaTypes.DOUBLE:
    case JavaTypes.DOUBLE_OBJ:
        if (precis > 0 || scale > 0) {
            return getPreferredType(Types.NUMERIC);
        } else {
            return getPreferredType(Types.DOUBLE);
        }
    case JavaTypes.FLOAT:
    case JavaTypes.FLOAT_OBJ:
        if (precis > 0 || scale > 0) {
            return getPreferredType(Types.NUMERIC);
        } else {
            return getPreferredType(Types.REAL);
        }
    case JavaTypes.INT:
    case JavaTypes.INT_OBJ:
        return getPreferredType(Types.INTEGER);
    case JavaTypes.LONG:
    case JavaTypes.LONG_OBJ:
        return getPreferredType(Types.BIGINT);
    case JavaTypes.SHORT:
    case JavaTypes.SHORT_OBJ:
        return getPreferredType(Types.SMALLINT);
    case JavaTypes.STRING:
    case JavaTypes.LOCALE:
    case JavaSQLTypes.ASCII_STREAM:
    case JavaSQLTypes.CHAR_STREAM:
        return getPreferredType(Types.VARCHAR);
    case JavaTypes.BIGINTEGER:
        if (storeLargeNumbersAsStrings)
            return getPreferredType(Types.VARCHAR);
        return getPreferredType(Types.BIGINT);
    case JavaTypes.BIGDECIMAL:
        if (storeLargeNumbersAsStrings)
            return getPreferredType(Types.VARCHAR);
        return getPreferredType(Types.NUMERIC);
    case JavaTypes.NUMBER:
        if (storeLargeNumbersAsStrings)
            return getPreferredType(Types.VARCHAR);
        return getPreferredType(Types.NUMERIC);
    case JavaTypes.CALENDAR:
    case JavaTypes.DATE:
        return getPreferredType(Types.TIMESTAMP);
    case JavaSQLTypes.SQL_ARRAY:
        return getPreferredType(Types.ARRAY);
    case JavaSQLTypes.BINARY_STREAM:
    case JavaSQLTypes.BLOB:
    case JavaSQLTypes.BYTES:
        return getPreferredType(Types.BLOB);
    case JavaSQLTypes.CLOB:
        return getPreferredType(Types.CLOB);
    case JavaSQLTypes.SQL_DATE:
        return getPreferredType(Types.DATE);
    case JavaSQLTypes.TIME:
        return getPreferredType(Types.TIME);
    case JavaSQLTypes.TIMESTAMP:
        return getPreferredType(Types.TIMESTAMP);
    default:
        return getPreferredType(Types.BLOB);
    }
}

From source file:helma.objectmodel.db.NodeManager.java

private void setStatementValue(PreparedStatement stmt, int stmtNumber, Property p, int columnType)
        throws SQLException {
    if (p.getValue() == null) {
        stmt.setNull(stmtNumber, columnType);
    } else {//ww  w  .j  a  va2 s.c  om
        switch (columnType) {
        case Types.BIT:
        case Types.BOOLEAN:
            stmt.setBoolean(stmtNumber, p.getBooleanValue());

            break;

        case Types.TINYINT:
        case Types.BIGINT:
        case Types.SMALLINT:
        case Types.INTEGER:
            stmt.setLong(stmtNumber, p.getIntegerValue());

            break;

        case Types.REAL:
        case Types.FLOAT:
        case Types.DOUBLE:
        case Types.NUMERIC:
        case Types.DECIMAL:
            stmt.setDouble(stmtNumber, p.getFloatValue());

            break;

        case Types.LONGVARBINARY:
        case Types.VARBINARY:
        case Types.BINARY:
        case Types.BLOB:
            Object b = p.getJavaObjectValue();
            if (b instanceof byte[]) {
                byte[] buf = (byte[]) b;
                try {
                    stmt.setBytes(stmtNumber, buf);
                } catch (SQLException x) {
                    ByteArrayInputStream bout = new ByteArrayInputStream(buf);
                    stmt.setBinaryStream(stmtNumber, bout, buf.length);
                }
            } else {
                throw new SQLException(
                        "expected byte[] for binary column '" + p.getName() + "', found " + b.getClass());
            }

            break;

        case Types.LONGVARCHAR:
            try {
                stmt.setString(stmtNumber, p.getStringValue());
            } catch (SQLException x) {
                String str = p.getStringValue();
                Reader r = new StringReader(str);
                stmt.setCharacterStream(stmtNumber, r, str.length());
            }

            break;

        case Types.CLOB:
            String val = p.getStringValue();
            Reader isr = new StringReader(val);
            stmt.setCharacterStream(stmtNumber, isr, val.length());

            break;

        case Types.CHAR:
        case Types.VARCHAR:
        case Types.OTHER:
            stmt.setString(stmtNumber, p.getStringValue());

            break;

        case Types.DATE:
        case Types.TIME:
        case Types.TIMESTAMP:
            stmt.setTimestamp(stmtNumber, p.getTimestampValue());

            break;

        case Types.NULL:
            stmt.setNull(stmtNumber, 0);

            break;

        default:
            stmt.setString(stmtNumber, p.getStringValue());

            break;
        }
    }
}

From source file:org.jumpmind.db.platform.AbstractDdlBuilder.java

/**
 * Generates the string representation of the given value.
 *
 * @param column//from   w ww.ja  va 2 s . com
 *            The column
 * @param value
 *            The value
 * @return The string representation
 */
protected String getValueAsString(Column column, Object value) {
    if (value == null) {
        return "NULL";
    }

    StringBuffer result = new StringBuffer();

    // TODO: Handle binary types (BINARY, VARBINARY, LONGVARBINARY, BLOB)
    switch (column.getMappedTypeCode()) {
    case Types.DATE:
        result.append(databaseInfo.getValueQuoteToken());
        if (!(value instanceof String) && (getValueDateFormat() != null)) {
            // TODO: Can the format method handle java.sql.Date properly
            // ?
            result.append(getValueDateFormat().format(value));
        } else {
            result.append(value.toString());
        }
        result.append(databaseInfo.getValueQuoteToken());
        break;
    case Types.TIME:
        result.append(databaseInfo.getValueQuoteToken());
        if (!(value instanceof String) && (getValueTimeFormat() != null)) {
            // TODO: Can the format method handle java.sql.Date properly
            // ?
            result.append(getValueTimeFormat().format(value));
        } else {
            result.append(value.toString());
        }
        result.append(databaseInfo.getValueQuoteToken());
        break;
    case Types.TIMESTAMP:
        result.append(databaseInfo.getValueQuoteToken());
        // TODO: SimpleDateFormat does not support nano seconds so we
        // would
        // need a custom date formatter for timestamps
        result.append(value.toString());
        result.append(databaseInfo.getValueQuoteToken());
        break;
    case Types.REAL:
    case Types.NUMERIC:
    case Types.FLOAT:
    case Types.DOUBLE:
    case Types.DECIMAL:
        result.append(databaseInfo.getValueQuoteToken());
        if (!(value instanceof String) && (getValueNumberFormat() != null)) {
            result.append(getValueNumberFormat().format(value));
        } else {
            result.append(value.toString());
        }
        result.append(databaseInfo.getValueQuoteToken());
        break;
    default:
        result.append(databaseInfo.getValueQuoteToken());
        result.append(escapeStringValue(value.toString()));
        result.append(databaseInfo.getValueQuoteToken());
        break;
    }
    return result.toString();
}