Example usage for java.sql Types BLOB

List of usage examples for java.sql Types BLOB

Introduction

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

Prototype

int BLOB

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

Click Source Link

Document

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

Usage

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

/**
 * Set a column value into a prepared statement.
 *
 * @param stmnt the prepared statement to parameterize
 * @param idx the index of the parameter in the prepared statement
 * @param val the value of the column/*from  www  . j  a v a2s .c  om*/
 * @param col the column being set
 * @param type the field mapping type code for the value
 * @param store the store manager for the current context
 */
public void setTyped(PreparedStatement stmnt, int idx, Object val, Column col, int type, JDBCStore store)
        throws SQLException {
    if (val == null) {
        setNull(stmnt, idx, (col == null) ? Types.OTHER : col.getType(), col);
        return;
    }

    Sized s;
    Calendard c;
    switch (type) {
    case JavaTypes.BOOLEAN:
    case JavaTypes.BOOLEAN_OBJ:
        setBoolean(stmnt, idx, ((Boolean) val).booleanValue(), col);
        break;
    case JavaTypes.BYTE:
    case JavaTypes.BYTE_OBJ:
        setByte(stmnt, idx, ((Number) val).byteValue(), col);
        break;
    case JavaTypes.CHAR:
    case JavaTypes.CHAR_OBJ:
        setChar(stmnt, idx, ((Character) val).charValue(), col);
        break;
    case JavaTypes.DOUBLE:
    case JavaTypes.DOUBLE_OBJ:
        setDouble(stmnt, idx, ((Number) val).doubleValue(), col);
        break;
    case JavaTypes.FLOAT:
    case JavaTypes.FLOAT_OBJ:
        setFloat(stmnt, idx, ((Number) val).floatValue(), col);
        break;
    case JavaTypes.INT:
    case JavaTypes.INT_OBJ:
        setInt(stmnt, idx, ((Number) val).intValue(), col);
        break;
    case JavaTypes.LONG:
    case JavaTypes.LONG_OBJ:
        setLong(stmnt, idx, ((Number) val).longValue(), col);
        break;
    case JavaTypes.SHORT:
    case JavaTypes.SHORT_OBJ:
        setShort(stmnt, idx, ((Number) val).shortValue(), col);
        break;
    case JavaTypes.STRING:
        if (col != null && (col.getType() == Types.CLOB || col.getType() == Types.LONGVARCHAR))
            setClobString(stmnt, idx, (String) val, col);
        else {
            if (val instanceof String)
                setString(stmnt, idx, (String) val, col);
            else
                setString(stmnt, idx, val.toString(), col);
        }
        break;
    case JavaTypes.OBJECT:
        setBlobObject(stmnt, idx, val, col, store);
        break;
    case JavaTypes.DATE:
        setDate(stmnt, idx, (Date) val, col);
        break;
    case JavaTypes.CALENDAR:
        setCalendar(stmnt, idx, (Calendar) val, col);
        break;
    case JavaTypes.BIGDECIMAL:
        setBigDecimal(stmnt, idx, (BigDecimal) val, col);
        break;
    case JavaTypes.BIGINTEGER:
        setBigInteger(stmnt, idx, (BigInteger) val, col);
        break;
    case JavaTypes.NUMBER:
        setNumber(stmnt, idx, (Number) val, col);
        break;
    case JavaTypes.LOCALE:
        setLocale(stmnt, idx, (Locale) val, col);
        break;
    case JavaSQLTypes.SQL_ARRAY:
        setArray(stmnt, idx, (Array) val, col);
        break;
    case JavaSQLTypes.ASCII_STREAM:
        s = (Sized) val;
        setAsciiStream(stmnt, idx, (InputStream) s.value, s.size, col);
        break;
    case JavaSQLTypes.BINARY_STREAM:
        s = (Sized) val;
        setBinaryStream(stmnt, idx, (InputStream) s.value, s.size, col);
        break;
    case JavaSQLTypes.BLOB:
        setBlob(stmnt, idx, (Blob) val, col);
        break;
    case JavaSQLTypes.BYTES:
        setBytes(stmnt, idx, (byte[]) val, col);
        break;
    case JavaSQLTypes.CHAR_STREAM:
        s = (Sized) val;
        setCharacterStream(stmnt, idx, (Reader) s.value, s.size, col);
        break;
    case JavaSQLTypes.CLOB:
        setClob(stmnt, idx, (Clob) val, col);
        break;
    case JavaSQLTypes.SQL_DATE:
        if (val instanceof Calendard) {
            c = (Calendard) val;
            setDate(stmnt, idx, (java.sql.Date) c.value, c.calendar, col);
        } else
            setDate(stmnt, idx, (java.sql.Date) val, null, col);
        break;
    case JavaSQLTypes.REF:
        setRef(stmnt, idx, (Ref) val, col);
        break;
    case JavaSQLTypes.TIME:
        if (val instanceof Calendard) {
            c = (Calendard) val;
            setTime(stmnt, idx, (Time) c.value, c.calendar, col);
        } else
            setTime(stmnt, idx, (Time) val, null, col);
        break;
    case JavaSQLTypes.TIMESTAMP:
        if (val instanceof Calendard) {
            c = (Calendard) val;
            setTimestamp(stmnt, idx, (Timestamp) c.value, c.calendar, col);
        } else
            setTimestamp(stmnt, idx, (Timestamp) val, null, col);
        break;
    default:
        if (col != null && (col.getType() == Types.BLOB || col.getType() == Types.VARBINARY))
            setBlobObject(stmnt, idx, val, col, store);
        else
            setObject(stmnt, idx, val, col.getType(), col);
    }
}

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

/**
 *  Create a new Node from a ResultSet.//  w w  w.ja  va  2s. c  o  m
 */
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:com.manydesigns.portofino.actions.admin.appwizard.ApplicationWizard.java

protected boolean isUnsupportedProperty(Column column) {
    // I blob su db non sono supportati al momento
    return column.getJdbcType() == Types.BLOB || column.getJdbcType() == Types.LONGVARBINARY;
}

From source file:org.apache.qpid.server.store.derby.DerbyMessageStore.java

private void insertConfiguredObject(ConfiguredObjectRecord configuredObject) throws AMQStoreException {
    if (_stateManager.isInState(State.ACTIVE)) {
        try {//from   www. j  a  v a 2s. c om
            Connection conn = newAutoCommitConnection();
            try {
                PreparedStatement stmt = conn.prepareStatement(FIND_CONFIGURED_OBJECT);
                try {
                    stmt.setString(1, configuredObject.getId().toString());
                    ResultSet rs = stmt.executeQuery();
                    try {
                        // If we don't have any data in the result set then we can add this configured object
                        if (!rs.next()) {
                            PreparedStatement insertStmt = conn
                                    .prepareStatement(INSERT_INTO_CONFIGURED_OBJECTS);
                            try {
                                insertStmt.setString(1, configuredObject.getId().toString());
                                insertStmt.setString(2, configuredObject.getType());
                                if (configuredObject.getAttributes() == null) {
                                    insertStmt.setNull(3, Types.BLOB);
                                } else {
                                    byte[] attributesAsBytes = configuredObject.getAttributes()
                                            .getBytes(UTF8_CHARSET);
                                    ByteArrayInputStream bis = new ByteArrayInputStream(attributesAsBytes);
                                    insertStmt.setBinaryStream(3, bis, attributesAsBytes.length);
                                }
                                insertStmt.execute();
                            } finally {
                                insertStmt.close();
                            }
                        }
                    } finally {
                        rs.close();
                    }
                } finally {
                    stmt.close();
                }
            } finally {
                conn.close();
            }
        } catch (SQLException e) {
            throw new AMQStoreException("Error inserting of configured object " + configuredObject
                    + " into database: " + e.getMessage(), e);
        }
    }
}

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  w w.  j av  a 2  s. c o  m
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:org.apache.qpid.server.store.derby.DerbyMessageStore.java

private void updateConfiguredObject(final ConfiguredObjectRecord configuredObject) throws AMQStoreException {
    if (_stateManager.isInState(State.ACTIVE)) {
        try {//w ww .j a va 2 s. c o m
            Connection conn = newAutoCommitConnection();
            try {
                PreparedStatement stmt = conn.prepareStatement(FIND_CONFIGURED_OBJECT);
                try {
                    stmt.setString(1, configuredObject.getId().toString());
                    ResultSet rs = stmt.executeQuery();
                    try {
                        if (rs.next()) {
                            PreparedStatement stmt2 = conn.prepareStatement(UPDATE_CONFIGURED_OBJECTS);
                            try {
                                stmt2.setString(1, configuredObject.getType());
                                if (configuredObject.getAttributes() != null) {
                                    byte[] attributesAsBytes = configuredObject.getAttributes()
                                            .getBytes(UTF8_CHARSET);
                                    ByteArrayInputStream bis = new ByteArrayInputStream(attributesAsBytes);
                                    stmt2.setBinaryStream(2, bis, attributesAsBytes.length);
                                } else {
                                    stmt2.setNull(2, Types.BLOB);
                                }
                                stmt2.setString(3, configuredObject.getId().toString());
                                stmt2.execute();
                            } finally {
                                stmt2.close();
                            }
                        }
                    } finally {
                        rs.close();
                    }
                } finally {
                    stmt.close();
                }
            } finally {
                conn.close();
            }
        } catch (SQLException e) {
            throw new AMQStoreException(
                    "Error updating configured object " + configuredObject + " in database: " + e.getMessage(),
                    e);
        }
    }
}

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 {//from  www  .ja v  a2  s  .co  m
        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.alfresco.repo.domain.schema.SchemaBootstrap.java

/**
 * Performs dialect-specific checking.  This includes checking for InnoDB, dumping the dialect being used
 * as well as setting any runtime, dialect-specific properties.
 *//*from   ww w  .jav  a  2s. co  m*/
private void checkDialect(Dialect dialect) {
    Class<?> dialectClazz = dialect.getClass();
    LogUtil.info(logger, MSG_DIALECT_USED, dialectClazz.getName());
    if (dialectClazz.equals(MySQLDialect.class) || dialectClazz.equals(MySQL5Dialect.class)) {
        LogUtil.error(logger, ERR_DIALECT_SHOULD_USE, dialectClazz.getName(),
                MySQLInnoDBDialect.class.getName());
        throw AlfrescoRuntimeException.create(WARN_DIALECT_UNSUPPORTED, dialectClazz.getName());
    } else if (dialectClazz.equals(HSQLDialect.class)) {
        LogUtil.info(logger, WARN_DIALECT_HSQL);
    } else if (dialectClazz.equals(DerbyDialect.class)) {
        LogUtil.info(logger, WARN_DIALECT_DERBY);
    } else if (dialectClazz.equals(Oracle9iDialect.class) || dialectClazz.equals(Oracle10gDialect.class)) {
        LogUtil.error(logger, ERR_DIALECT_SHOULD_USE, dialectClazz.getName(),
                AlfrescoOracle9Dialect.class.getName());
        throw AlfrescoRuntimeException.create(WARN_DIALECT_UNSUPPORTED, dialectClazz.getName());
    } else if (dialectClazz.equals(OracleDialect.class) || dialectClazz.equals(Oracle9Dialect.class)) {
        LogUtil.error(logger, ERR_DIALECT_SHOULD_USE, dialectClazz.getName(),
                AlfrescoOracle9Dialect.class.getName());
        throw AlfrescoRuntimeException.create(WARN_DIALECT_UNSUPPORTED, dialectClazz.getName());
    }

    int maxStringLength = SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH;
    int serializableType = SerializableTypeHandler.getSerializableType();
    // Adjust the maximum allowable String length according to the dialect
    if (dialect instanceof AlfrescoSQLServerDialect) {
        // string_value nvarchar(1024) null,
        // serializable_value image null,
        maxStringLength = SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH;
    } else if (dialect instanceof AlfrescoSybaseAnywhereDialect) {
        // string_value text null,
        // serializable_value varbinary(8192) null,
        maxStringLength = Integer.MAX_VALUE;
    } else if (dialect instanceof DB2Dialect) {
        // string_value varchar(1024),
        // serializable_value varchar(8192) for bit data,
        maxStringLength = SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH;
        serializableType = Types.BLOB;
    } else if (dialect instanceof HSQLDialect) {
        // string_value varchar(1024),
        // serializable_value varbinary(8192),
        maxStringLength = SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH;
    } else if (dialect instanceof AlfrescoMySQLClusterNDBDialect) {
        // string_value varchar(400),
        // serializable_value blob,
        maxStringLength = SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH_NDB;
    } else if (dialect instanceof MySQLInnoDBDialect) {
        // string_value text,
        // serializable_value blob,
        maxStringLength = Integer.MAX_VALUE;
    } else if (dialect instanceof AlfrescoOracle9Dialect) {
        // string_value varchar2(1024 char),
        // serializable_value blob,
        maxStringLength = SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH;
    } else if (dialect instanceof PostgreSQLDialect) {
        // string_value varchar(1024),
        // serializable_value bytea,
        maxStringLength = SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH;
    }

    SchemaBootstrap.setMaxStringLength(maxStringLength, dialect);
    SerializableTypeHandler.setSerializableType(serializableType);

    // Now override the maximum string length if it was set directly
    if (maximumStringLength > 0) {
        SchemaBootstrap.setMaxStringLength(maximumStringLength, dialect);
    }
}

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

/**
 * Returns the type name for the specific constant as defined
 * by {@link java.sql.Types}.// ww  w  .  j ava 2  s  .c  om
 *
 * @param type the type
 * @return the name for the type
 */
public String getTypeName(int type) {
    switch (type) {
    case Types.ARRAY:
        return arrayTypeName;
    case Types.BIGINT:
        return bigintTypeName;
    case Types.BINARY:
        return binaryTypeName;
    case Types.BIT:
        return bitTypeName;
    case Types.BLOB:
        return blobTypeName;
    case Types.BOOLEAN:
        return booleanTypeName;
    case Types.CHAR:
        return charTypeName;
    case Types.CLOB:
        return clobTypeName;
    case Types.DATE:
        return dateTypeName;
    case Types.DECIMAL:
        return decimalTypeName;
    case Types.DISTINCT:
        return distinctTypeName;
    case Types.DOUBLE:
        return doubleTypeName;
    case Types.FLOAT:
        return floatTypeName;
    case Types.INTEGER:
        return integerTypeName;
    case Types.JAVA_OBJECT:
        return javaObjectTypeName;
    case Types.LONGVARBINARY:
        return longVarbinaryTypeName;
    case Types.LONGVARCHAR:
        return longVarcharTypeName;
    case Types.NULL:
        return nullTypeName;
    case Types.NUMERIC:
        return numericTypeName;
    case Types.OTHER:
        return otherTypeName;
    case Types.REAL:
        return realTypeName;
    case Types.REF:
        return refTypeName;
    case Types.SMALLINT:
        return smallintTypeName;
    case Types.STRUCT:
        return structTypeName;
    case Types.TIME:
        return timeTypeName;
    case Types.TIMESTAMP:
        return timestampTypeName;
    case Types.TINYINT:
        return tinyintTypeName;
    case Types.VARBINARY:
        return varbinaryTypeName;
    case Types.VARCHAR:
        return varcharTypeName;
    default:
        return otherTypeName;
    }
}

From source file:org.wso2.carbon.dataservices.core.description.query.SQLQuery.java

private void setBlobValue(int queryType, String paramName, String value, String paramType,
        PreparedStatement sqlQuery, int i) throws SQLException, DataServiceFault {
    if ("IN".equals(paramType)) {
        if (value == null) {
            sqlQuery.setNull(i + 1, java.sql.Types.BLOB);
        } else {/*from  w  w  w .  j a  v  a 2 s . c  o m*/
            byte[] data = this.getBytesFromBase64String(value);
            sqlQuery.setBlob(i + 1, new ByteArrayInputStream(data), data.length);
        }
    } else if ("INOUT".equals(paramType)) {
        if (value == null) {
            ((CallableStatement) sqlQuery).setNull(i + 1, java.sql.Types.BLOB);
        } else {
            byte[] data = this.getBytesFromBase64String(value);
            ((CallableStatement) sqlQuery).setBlob(i + 1, new ByteArrayInputStream(data), data.length);
        }
        ((CallableStatement) sqlQuery).registerOutParameter(i + 1, java.sql.Types.BLOB);
    } else {
        ((CallableStatement) sqlQuery).registerOutParameter(i + 1, java.sql.Types.BLOB);
    }
}