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:Main.java

public static String getCloverTypeFromJdbcType(int jdbcDataType) {
    switch (jdbcDataType) {
    case Types.DATE:
    case Types.TIME:
    case Types.TIMESTAMP:
        return "date";
    case Types.ARRAY:
    case Types.BINARY:
    case Types.DATALINK:
    case Types.BLOB:
    case Types.DISTINCT:
    case Types.JAVA_OBJECT:
    case Types.NULL:
    case Types.OTHER:
    case Types.REF:
    case Types.STRUCT:
    case Types.VARBINARY:
    case Types.LONGVARBINARY:
        System.out.println("Outputting cbyte for Type: " + jdbcDataType);
        return "cbyte";
    case Types.BIT:
    case Types.BOOLEAN:
        return "boolean";
    case Types.DECIMAL:
    case Types.DOUBLE:
    case Types.FLOAT:
    case Types.NUMERIC:
    case Types.REAL:
        return "numeric";
    case Types.INTEGER:
    case Types.SMALLINT:
        return "integer";
    case Types.BIGINT:
        return "long";
    case Types.CHAR:
    case Types.VARCHAR:
    case Types.CLOB:
    case Types.LONGVARCHAR:
        return "string";
    }/*from w w w . j ava2  s.c  om*/
    System.out.println("Outputting string for unknown Type: " + jdbcDataType);
    return "string";
}

From source file:Main.java

/**
 * Gets the name of the type to be used with the internal dbms
 * /*w  w  w . j a  v a2  s  .com*/
 * @param type
 *            java.sql.Types constant
 * 
 * @return String
 * 
 * @throws RuntimeException
 *             If the Type is not recognized
 */
public static String getTypeString(int type) {
    switch (type) {
    case Types.BIGINT:
        return "BIGINT";

    case Types.BIT:
    case Types.BOOLEAN:
        return "BOOLEAN";

    case Types.CHAR:
    case Types.VARCHAR:
    case Types.LONGVARCHAR:
        return "VARCHAR";

    case Types.DATE:
        return "DATE";

    case Types.DECIMAL:
    case Types.NUMERIC:
    case Types.FLOAT:
    case Types.DOUBLE:
    case Types.REAL:
        return "DOUBLE";

    case Types.INTEGER:
        return "INTEGER";

    case Types.SMALLINT:
        return "SHORT";

    case Types.TINYINT:
        return "BYTE";

    case Types.BINARY:
    case Types.VARBINARY:
    case Types.LONGVARBINARY:
        return "BINARY";

    case Types.TIMESTAMP:
        return "TIMESTAMP";

    case Types.TIME:
        return "TIME";

    default:
        throw new RuntimeException("Cannot edit the type: " + type);
    }
}

From source file:org.pentaho.reporting.engine.classic.core.modules.misc.tablemodel.TypeMapper.java

private static Class mapSQLType(final int t) {
    switch (t) {//from w w  w .  ja  v a2  s .  c om
    case Types.ARRAY:
        return Object[].class;
    case Types.BIGINT:
        return Long.class;
    case Types.BINARY:
        return byteArrayClass;
    case Types.BIT:
        return Boolean.class;
    case Types.BLOB:
        return Blob.class;
    case Types.BOOLEAN: // Types.BOOLEAN was not part of JDK1.2.2
        return Boolean.class;
    case Types.CHAR:
        return String.class;
    case Types.CLOB:
        return Clob.class;
    case Types.DATALINK: // Types.DATALINK was not part of JDK 1.2.2
        return URL.class;
    case Types.DATE:
        return java.sql.Date.class;
    case Types.DECIMAL:
        return java.math.BigDecimal.class;
    case Types.DISTINCT:
        return Object.class;
    case Types.DOUBLE:
        return Double.class;
    case Types.FLOAT:
        return Double.class;
    case Types.INTEGER:
        return Integer.class;
    case Types.JAVA_OBJECT:
        return Object.class;
    case Types.LONGVARBINARY:
        return byteArrayClass;
    case Types.LONGVARCHAR:
        return String.class;
    case Types.NCLOB:
        return NClob.class;
    case Types.NULL:
        return Object.class;
    case Types.NUMERIC:
        return java.math.BigDecimal.class;
    case Types.NCHAR:
    case Types.NVARCHAR:
    case Types.LONGNVARCHAR:
        return String.class;
    case Types.OTHER:
        return Object.class;
    case Types.REAL:
        return Float.class;
    case Types.REF:
        return Ref.class;
    case Types.ROWID:
        return RowId.class;
    case Types.SMALLINT:
        return Short.class;
    case Types.STRUCT:
        return Struct.class;
    case Types.SQLXML:
        return SQLXML.class;
    case Types.TIME:
        return Time.class;
    case Types.TIMESTAMP:
        return Timestamp.class;
    case Types.TINYINT:
        return Byte.class;
    case Types.VARBINARY:
        return byteArrayClass;
    case Types.VARCHAR:
        return String.class;
    default:
        return Object.class;
    }
}

From source file:com.espertech.esper.util.TestSQLTypeMapUtil.java

public void testMapping() {
    Map<Integer, Class> testData = new HashMap<Integer, Class>();
    testData.put(Types.CHAR, String.class);
    testData.put(Types.VARCHAR, String.class);
    testData.put(Types.LONGVARCHAR, String.class);
    testData.put(Types.NUMERIC, BigDecimal.class);
    testData.put(Types.DECIMAL, BigDecimal.class);
    testData.put(Types.BIT, Boolean.class);
    testData.put(Types.BOOLEAN, Boolean.class);
    testData.put(Types.TINYINT, Byte.class);
    testData.put(Types.SMALLINT, Short.class);
    testData.put(Types.INTEGER, Integer.class);
    testData.put(Types.BIGINT, Long.class);
    testData.put(Types.REAL, Float.class);
    testData.put(Types.FLOAT, Double.class);
    testData.put(Types.DOUBLE, Double.class);
    testData.put(Types.BINARY, byte[].class);
    testData.put(Types.VARBINARY, byte[].class);
    testData.put(Types.LONGVARBINARY, byte[].class);
    testData.put(Types.DATE, java.sql.Date.class);
    testData.put(Types.TIMESTAMP, java.sql.Timestamp.class);
    testData.put(Types.TIME, java.sql.Time.class);
    testData.put(Types.CLOB, java.sql.Clob.class);
    testData.put(Types.BLOB, java.sql.Blob.class);
    testData.put(Types.ARRAY, java.sql.Array.class);
    testData.put(Types.STRUCT, java.sql.Struct.class);
    testData.put(Types.REF, java.sql.Ref.class);
    testData.put(Types.DATALINK, java.net.URL.class);

    for (int type : testData.keySet()) {
        Class result = SQLTypeMapUtil.sqlTypeToClass(type, null);
        log.debug(".testMapping Mapping " + type + " to " + result.getSimpleName());
        assertEquals(testData.get(type), result);
    }/*www .j  ava 2  s. c o m*/

    assertEquals(String.class, SQLTypeMapUtil.sqlTypeToClass(Types.JAVA_OBJECT, "java.lang.String"));
    assertEquals(String.class, SQLTypeMapUtil.sqlTypeToClass(Types.DISTINCT, "java.lang.String"));
}

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

/**
 * Return the SQL type name for the given {@link Types} constant.
 *///from   w w  w  .  j ava 2s  .c o m
public static String getJDBCName(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.CHAR:
        return "char";
    case Types.CLOB:
        return "clob";
    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 "unknown(" + type + ")";
    }
}

From source file:org.apache.ojb.broker.metadata.FieldTypeClasses.java

/**
 * Returns a {@link FieldType} instance for the given sql type
 * (see {@link java.sql.Types}) as specified in JDBC 3.0 specification
 * (see JDBC 3.0 specification <em>Appendix B, Data Type Conversion Tables</em>).
 *
 * @param jdbcType Specify the type to look for.
 * @return A new specific {@link FieldType} instance.
 *///from   ww w . j a  v a2 s . co  m
static FieldType newFieldType(JdbcType jdbcType) {
    FieldType result = null;
    switch (jdbcType.getType()) {
    case Types.ARRAY:
        result = new ArrayFieldType();
        break;
    case Types.BIGINT:
        result = new LongFieldType();
        break;
    case Types.BINARY:
        result = new ByteArrayFieldType();
        break;
    case Types.BIT:
        result = new BooleanFieldType();
        break;
    case Types.BLOB:
        result = new BlobFieldType();
        break;
    case Types.CHAR:
        result = new StringFieldType();
        break;
    case Types.CLOB:
        result = new ClobFieldType();
        break;
    case Types.DATE:
        result = new DateFieldType();
        break;
    case Types.DECIMAL:
        result = new BigDecimalFieldType();
        break;
    // Not needed, user have to use the underlying sql datatype in OJB mapping files
    //            case Types.DISTINCT:
    //                result = new DistinctFieldType();
    //                break;
    case Types.DOUBLE:
        result = new DoubleFieldType();
        break;
    case Types.FLOAT:
        result = new FloatFieldType();
        break;
    case Types.INTEGER:
        result = new IntegerFieldType();
        break;
    case Types.JAVA_OBJECT:
        result = new JavaObjectFieldType();
        break;
    case Types.LONGVARBINARY:
        result = new ByteArrayFieldType();
        break;
    case Types.LONGVARCHAR:
        result = new StringFieldType();
        break;
    case Types.NUMERIC:
        result = new BigDecimalFieldType();
        break;
    case Types.REAL:
        result = new FloatFieldType();
        break;
    case Types.REF:
        result = new RefFieldType();
        break;
    case Types.SMALLINT:
        result = new ShortFieldType();
        break;
    case Types.STRUCT:
        result = new StructFieldType();
        break;
    case Types.TIME:
        result = new TimeFieldType();
        break;
    case Types.TIMESTAMP:
        result = new TimestampFieldType();
        break;
    case Types.TINYINT:
        result = new ByteFieldType();
        break;
    case Types.VARBINARY:
        result = new ByteArrayFieldType();
        break;
    case Types.VARCHAR:
        result = new StringFieldType();
        break;
    case Types.OTHER:
        result = new JavaObjectFieldType();
        break;
    //
    //            case Types.NULL:
    //                result = new NullFieldType();
    //                break;

    //#ifdef JDBC30
    case Types.BOOLEAN:
        result = new BooleanFieldType();
        break;
    case Types.DATALINK:
        result = new URLFieldType();
        break;
    //#endif
    default:
        throw new OJBRuntimeException("Unkown or not supported field type specified, specified jdbc type was '"
                + jdbcType + "', as string: " + JdbcTypesHelper.getSqlTypeAsString(jdbcType.getType()));
    }
    // make sure that the sql type was set
    result.setSqlType(jdbcType);
    return result;
}

From source file:org.sakaiproject.mailarchive.impl.conversion.ExtractXMLToColumns.java

public Object getSource(String id, ResultSet rs) throws SQLException {
    ResultSetMetaData metadata = rs.getMetaData();
    String rv = null;//ww  w  . j  a v  a2  s.c  o m
    switch (metadata.getColumnType(1)) {
    case Types.BLOB:
        Blob blob = rs.getBlob(1);
        if (blob != null) {
            rv = new String(blob.getBytes(1L, (int) blob.length()));
        }
        break;
    case Types.CLOB:
        Clob clob = rs.getClob(1);
        if (clob != null) {
            rv = clob.getSubString(1L, (int) clob.length());
        }
        break;
    case Types.CHAR:
    case Types.LONGVARCHAR:
    case Types.VARCHAR:
    case Types.BINARY:
    case Types.VARBINARY:
    case Types.LONGVARBINARY:
        byte[] bytes = rs.getBytes(1);
        if (bytes != null) {
            rv = new String(bytes);
        }
        break;
    }
    // System.out.println("getSource(" + id + ") \n" + rv + "\n");
    return rv;
}

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

public boolean isBlob() {

    return (dataType == Types.BLOB || dataType == Types.BINARY || dataType == Types.VARBINARY
            || dataType == Types.LONGVARBINARY);
}

From source file:org.sakaiproject.content.impl.serialize.impl.conversion.Type1BlobCollectionConversionHandler.java

public Object getSource(String id, ResultSet rs) throws SQLException {
    ResultSetMetaData metadata = rs.getMetaData();
    String rv = null;/*from   w w w .ja v  a  2 s  .  co m*/
    switch (metadata.getColumnType(1)) {
    case Types.BLOB:
        Blob blob = rs.getBlob(1);
        if (blob != null) {
            rv = new String(blob.getBytes(1L, (int) blob.length()));
        }
        break;
    case Types.CLOB:
        Clob clob = rs.getClob(1);
        if (clob != null) {
            rv = clob.getSubString(1L, (int) clob.length());
        }
        break;
    case Types.CHAR:
    case Types.LONGVARCHAR:
    case Types.VARCHAR:
    case Types.BINARY:
    case Types.VARBINARY:
    case Types.LONGVARBINARY:
        byte[] bytes = rs.getBytes(1);
        if (bytes != null) {
            rv = new String(bytes);
        }
        break;
    }
    //System.out.println("getSource(" + id + ") \n" + rv + "\n");
    return rv;
}

From source file:RowSetModel.java

public Class getColumnClass(int column) {
    String cname;/*from ww  w.j  a  va  2 s . c om*/
    int type;

    try {
        ResultSetMetaData meta = rowSet.getMetaData();

        if (meta == null) {
            return null;
        }
        type = meta.getColumnType(column + 1);
    } catch (SQLException e) {
        e.printStackTrace();
        return super.getColumnClass(column);
    }
    switch (type) {
    case Types.BIT: {
        cname = "java.lang.Boolean";
        break;
    }
    case Types.TINYINT: {
        cname = "java.lang.Byte";
        break;
    }
    case Types.SMALLINT: {
        cname = "java.lang.Short";
        break;
    }
    case Types.INTEGER: {
        cname = "java.lang.Integer";
        break;
    }
    case Types.BIGINT: {
        cname = "java.lang.Long";
        break;
    }
    case Types.FLOAT:
    case Types.REAL: {
        cname = "java.lang.Float";
        break;
    }
    case Types.DOUBLE: {
        cname = "java.lang.Double";
        break;
    }
    case Types.NUMERIC: {
        cname = "java.lang.Number";
        break;
    }
    case Types.DECIMAL: {
        cname = "java.math.BigDecimal";
        break;
    }
    case Types.CHAR:
    case Types.VARCHAR:
    case Types.LONGVARCHAR: {
        cname = "java.lang.String";
        break;
    }
    case Types.DATE: {
        cname = "java.sql.Date";
        break;
    }
    case Types.TIME: {
        cname = "java.sql.Time";
        break;
    }
    case Types.TIMESTAMP: {
        cname = "java.sql.Timestamp";
        break;
    }
    case Types.BINARY:
    case Types.VARBINARY:
    case Types.LONGVARBINARY: {
        cname = "byte[]";
        break;
    }
    case Types.OTHER:
    case Types.JAVA_OBJECT: {
        cname = "java.lang.Object";
        break;
    }
    case Types.CLOB: {
        cname = "java.sql.Clob";
        break;
    }
    case Types.BLOB: {
        cname = "java.ssql.Blob";
        break;
    }
    case Types.REF: {
        cname = "java.sql.Ref";
        break;
    }
    case Types.STRUCT: {
        cname = "java.sql.Struct";
        break;
    }
    default: {
        return super.getColumnClass(column);
    }
    }
    try {
        return Class.forName(cname);
    } catch (Exception e) {
        e.printStackTrace();
        return super.getColumnClass(column);
    }
}