Example usage for java.sql Types LONGVARBINARY

List of usage examples for java.sql Types LONGVARBINARY

Introduction

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

Prototype

int LONGVARBINARY

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

Click Source Link

Document

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

Usage

From source file:org.opendatakit.common.persistence.engine.pgres.DatastoreImpl.java

public static void buildArgumentList(Object[] ol, int[] il, int idx, CommonFieldsBase entity, DataField f) {
    switch (f.getDataType()) {
    case BOOLEAN:
        ol[idx] = entity.getBooleanField(f);
        il[idx] = java.sql.Types.BOOLEAN;
        break;//ww  w .j a v  a  2 s.  c  o  m
    case STRING:
    case URI:
        ol[idx] = entity.getStringField(f);
        il[idx] = java.sql.Types.VARCHAR;
        break;
    case INTEGER:
        ol[idx] = entity.getLongField(f);
        il[idx] = java.sql.Types.BIGINT;
        break;
    case DECIMAL:
        ol[idx] = entity.getNumericField(f);
        il[idx] = java.sql.Types.DECIMAL;
        break;
    case DATETIME:
        ol[idx] = entity.getDateField(f);
        il[idx] = java.sql.Types.TIMESTAMP;
        break;
    case BINARY:
        ol[idx] = entity.getBlobField(f);
        il[idx] = java.sql.Types.LONGVARBINARY;
        break;
    case LONG_STRING:
        ol[idx] = entity.getStringField(f);
        il[idx] = java.sql.Types.LONGVARCHAR;
        break;

    default:
        throw new IllegalStateException("Unexpected data type");
    }
}

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

private String getTypeName(int SQLType) {
    switch (SQLType) {
    case Types.ARRAY:
        return "ARRAY";
    case Types.BIGINT:
        return "INTEGER";
    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.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.NCHAR:
        return "NCHAR";
    case Types.NCLOB:
        return "NCLOB";
    case Types.NULL:
        return "UNDEFINED";//
    case Types.NUMERIC:
        return "NUMERIC";
    case Types.NVARCHAR:
        return "NVARCHAR";
    case Types.OTHER:
        return "UNDEFINED";//
    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://  w  w  w  . java2  s . c o m
        return "UNDEFINED";//
    }
}

From source file:org.apache.cayenne.unit.di.server.SchemaBuilder.java

private void dbEntitiesFilter(List<DbEntity> entities) {
    // filter various unsupported tests...

    // LOBs/*  www  .  ja  va 2  s .  c o m*/
    boolean excludeLOB = !unitDbAdapter.supportsLobs();
    boolean excludeBinPK = !unitDbAdapter.supportsBinaryPK();
    if (excludeLOB || excludeBinPK) {

        List<DbEntity> filtered = new ArrayList<DbEntity>();

        for (DbEntity ent : entities) {

            // check for LOB attributes
            if (excludeLOB) {
                if (Arrays.binarySearch(EXTRA_EXCLUDED_FOR_NO_LOB, ent.getName()) >= 0) {
                    continue;
                }

                boolean hasLob = false;
                for (final DbAttribute attr : ent.getAttributes()) {
                    if (attr.getType() == Types.BLOB || attr.getType() == Types.CLOB) {
                        hasLob = true;
                        break;
                    }
                }

                if (hasLob) {
                    continue;
                }
            }

            // check for BIN PK
            if (excludeBinPK) {
                boolean skip = false;
                for (final DbAttribute attr : ent.getAttributes()) {
                    // check for BIN PK or FK to BIN Pk
                    if (attr.getType() == Types.BINARY || attr.getType() == Types.VARBINARY
                            || attr.getType() == Types.LONGVARBINARY) {

                        if (attr.isPrimaryKey() || attr.isForeignKey()) {
                            skip = true;
                            break;
                        }
                    }
                }

                if (skip) {
                    continue;
                }
            }

            filtered.add(ent);
        }

        entities = filtered;
    }
}

From source file:com.tesora.dve.db.NativeType.java

public boolean isBinaryType() {
    return dataType == Types.LONGVARBINARY || dataType == Types.BLOB || dataType == Types.BINARY
            || dataType == Types.VARBINARY;
}

From source file:org.netflux.core.FieldMetadata.java

/**
 * Returns a string representation of the provided type.
 * //from  ww w  . j ava 2s .  c om
 * @param type the type from {@link Types} to transform to a string.
 * @return a string representation of the provided type.
 */
public static String typeToString(int type) {
    switch (type) {
    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.LONGVARBINARY:
        return "LONGVARBINARY";

    case Types.LONGVARCHAR:
        return "LONGVARCHAR";

    case Types.NULL:
        return "NULL";

    case Types.NUMERIC:
        return "NUMERIC";

    case Types.OTHER:
        return "OTHER";

    case Types.REAL:
        return "REAL";

    case Types.REF:
        return "REF";

    case Types.SMALLINT:
        return "SMALLINT";

    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:
        return "*unsupported type*";
    }
}

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

public static int FromTypeName(String SQLName) {
    if (SQLName.equals("ARRAY")) {
        return Types.ARRAY;
    }//  w  ww  . j  a va 2 s . co m
    if (SQLName.equals("INTEGER")) {
        return Types.INTEGER;
    }
    if (SQLName.equals("BINARY")) {
        return Types.BINARY;
    }
    if (SQLName.equals("BIT")) {
        return Types.BIT;
    }
    if (SQLName.equals("BLOB")) {
        return Types.BLOB;
    }
    if (SQLName.equals("BOOLEAN")) {
        return Types.BOOLEAN;
    }
    if (SQLName.equals("CHAR")) {
        return Types.CHAR;
    }
    if (SQLName.equals("CLOB")) {
        return Types.CLOB;
    }
    if (SQLName.equals("DATALINK")) {
        return Types.DATALINK;
    }
    if (SQLName.equals("DATE")) {
        return Types.DATE;
    }
    if (SQLName.equals("DECIMAL")) {
        return Types.DECIMAL;
    }
    if (SQLName.equals("DOUBLE")) {
        return Types.DOUBLE;
    }
    if (SQLName.equals("FLOAT")) {
        return Types.FLOAT;
    }
    if (SQLName.equals("JAVA_OBJECT")) {
        return Types.JAVA_OBJECT;
    }
    if (SQLName.equals("LONGNVARCHAR")) {
        return Types.LONGNVARCHAR;
    }
    if (SQLName.equals("LONGVARBINARY")) {
        return Types.LONGVARBINARY;
    }
    if (SQLName.equals("NCHAR")) {
        return Types.NCHAR;
    }
    if (SQLName.equals("NCLOB")) {
        return Types.NCLOB;
    }
    if (SQLName.equals("UNDEFINED")) {
        return Types.OTHER;
    }
    if (SQLName.equals("NUMERIC")) {
        return Types.NUMERIC;
    }
    if (SQLName.equals("NVARCHAR")) {
        return Types.NVARCHAR;
    }
    if (SQLName.equals("REAL")) {
        return Types.REAL;
    }
    if (SQLName.equals("REF")) {
        return Types.REF;
    }
    if (SQLName.equals("ROWID")) {
        return Types.ROWID;
    }
    if (SQLName.equals("SMALLINT")) {
        return Types.SMALLINT;
    }
    if (SQLName.equals("SQLXML")) {
        return Types.SQLXML;
    }
    if (SQLName.equals("STRUCT")) {
        return Types.STRUCT;
    }
    if (SQLName.equals("TIME")) {
        return Types.TIME;
    }
    if (SQLName.equals("TIMESTAMP")) {
        return Types.TIMESTAMP;
    }
    if (SQLName.equals("TINYINT")) {
        return Types.TINYINT;
    }
    if (SQLName.equals("VARCHAR")) {
        return Types.VARCHAR;
    }
    if (SQLName.equals("VARBINARY")) {
        return Types.VARBINARY;
    }
    return Types.OTHER;
}

From source file:nl.nn.adapterframework.util.JdbcUtil.java

public static boolean isBlobType(final ResultSet rs, final int colNum, final ResultSetMetaData rsmeta)
        throws SQLException {
    switch (rsmeta.getColumnType(colNum)) {
    case Types.LONGVARBINARY:
    case Types.VARBINARY:
    case Types.BLOB:
        return true;
    default://from   w  ww .  j av a2s . co m
        return false;
    }
}

From source file:org.fastcatsearch.datasource.reader.DBReader.java

private void fill() throws IRException {

    bulkCount = 0;/* ww w .j  ava2  s.  c  om*/
    try {
        ResultSetMetaData rsMeta = null;
        //? Tmp ??? .
        deleteTmpLob();

        try {
            rsMeta = r.getMetaData();
        } catch (SQLException e) {
            return;
        }
        while (r.next()) {

            Map<String, Object> keyValueMap = new HashMap<String, Object>();

            for (int i = 0; i < columnCount; i++) {
                int columnIdx = i + 1;
                int type = rsMeta.getColumnType(columnIdx);

                String str = "";

                String lobType = null;
                if (type == Types.BLOB || type == Types.BINARY || type == Types.LONGVARBINARY
                        || type == Types.VARBINARY || type == Types.JAVA_OBJECT) {
                    lobType = LOB_BINARY;
                } else if (type == Types.CLOB || type == Types.NCLOB || type == Types.SQLXML
                        || type == Types.LONGVARCHAR || type == Types.LONGNVARCHAR) {
                    lobType = LOB_STRING;
                }

                if (lobType == null) {
                    str = r.getString(columnIdx);

                    if (str != null) {
                        keyValueMap.put(columnName[i], str);
                    } else {
                        //    ? ? ? NULL ? 
                        keyValueMap.put(columnName[i], "");
                    }
                } else {
                    File file = null;

                    if (lobType == LOB_BINARY) {
                        // logger.debug("Column-"+columnIdx+" is BLOB!");
                        // BLOB?   .
                        ByteArrayOutputStream buffer = null;
                        try {
                            if (!useBlobFile) {
                                buffer = new ByteArrayOutputStream();
                            }
                            file = readTmpBlob(i, columnIdx, rsMeta, buffer);
                            if (useBlobFile) {
                                keyValueMap.put(columnName[i], file);
                            } else {
                                keyValueMap.put(columnName[i], buffer.toByteArray());
                            }
                        } finally {
                            if (buffer != null) {
                                try {
                                    buffer.close();
                                } catch (IOException ignore) {
                                }
                            }
                        }
                    } else if (lobType == LOB_STRING) {
                        StringBuilder sb = null;
                        if (!useBlobFile) {
                            sb = new StringBuilder();
                        }
                        file = readTmpClob(i, columnIdx, rsMeta, sb);
                        if (useBlobFile) {
                            keyValueMap.put(columnName[i], file);
                        } else {
                            keyValueMap.put(columnName[i], sb.toString());
                        }
                    }

                    //?   ?? .
                    if (file != null) {
                        tmpFile.add(file);
                    }
                }
            }

            dataSet[bulkCount] = keyValueMap;
            bulkCount++;
            totalCnt++;

            if (bulkCount >= BULK_SIZE) {
                break;
            }
        }

    } catch (Exception e) {

        logger.debug("", e);

        try {
            if (r != null) {
                r.close();
            }
        } catch (SQLException ignore) {
        }

        try {
            if (pstmt != null) {
                pstmt.close();
            }
        } catch (SQLException ignore) {
        }

        try {
            if (con != null && !con.isClosed()) {
                con.close();
            }
        } catch (SQLException ignore) {
        }

        throw new IRException(e);
    }
}

From source file:nl.nn.adapterframework.util.JdbcUtil.java

public static String getValue(final ResultSet rs, final int colNum, final ResultSetMetaData rsmeta,
        String blobCharset, boolean decompressBlobs, String nullValue, boolean trimSpaces, boolean getBlobSmart,
        boolean encodeBlobBase64) throws JdbcException, IOException, SQLException, JMSException {
    switch (rsmeta.getColumnType(colNum)) {
    case Types.LONGVARBINARY:
    case Types.VARBINARY:
    case Types.BLOB:
        try {/* w w w.  j  ava 2s. co m*/
            return JdbcUtil.getBlobAsString(rs, colNum, blobCharset, false, decompressBlobs, getBlobSmart,
                    encodeBlobBase64);
        } catch (JdbcException e) {
            log.debug("Caught JdbcException, assuming no blob found", e);
            return nullValue;
        }
    case Types.CLOB:
        try {
            return JdbcUtil.getClobAsString(rs, colNum, false);
        } catch (JdbcException e) {
            log.debug("Caught JdbcException, assuming no clob found", e);
            return nullValue;
        }
        // return "undefined" for types that cannot be rendered to strings easily
    case Types.ARRAY:
    case Types.DISTINCT:
    case Types.BINARY:
    case Types.REF:
    case Types.STRUCT:
        return "undefined";
    default: {
        String value = rs.getString(colNum);
        if (value == null) {
            return nullValue;
        }
        if (trimSpaces) {
            return value.trim();
        }
        return value;
    }
    }
}

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

private String getSQLTypeFromInt(int t) {
    switch (t) {//  w  w  w. j ava2 s .co  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";
    }
}