List of usage examples for java.sql Types VARBINARY
int VARBINARY
To view the source code for java.sql Types VARBINARY.
Click Source Link
The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type VARBINARY
.
From source file:RowSetModel.java
public Class getColumnClass(int column) { String cname;//from w w w . j av a2 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); } }
From source file:org.hyperic.hibernate.dialect.MySQL5InnoDBDialect.java
public MySQL5InnoDBDialect() { super(); registerColumnType(Types.VARBINARY, 255, "blob"); }
From source file:org.pentaho.reporting.engine.classic.core.modules.misc.tablemodel.TypeMapper.java
private static Class mapSQLType(final int t) { switch (t) {//from ww w .j a v a 2 s .c o m 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:org.apache.openjpa.jdbc.schema.Schemas.java
/** * Return the SQL type name for the given {@link Types} constant. *//*from w ww .jav a2 s . 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:com.tesora.dve.sql.util.JdbcConnectionResourceResponse.java
@Override public List<ColumnChecker> getColumnCheckers() throws Throwable { ResultSetMetaData rsmd = results.getMetaData(); ArrayList<ColumnChecker> checkers = new ArrayList<ColumnChecker>(); for (int i = 1; i <= rsmd.getColumnCount(); i++) { int dt = rsmd.getColumnType(i); if (dt == Types.BINARY || dt == Types.VARBINARY || dt == Types.LONGVARBINARY) checkers.add(BLOB_COLUMN);/*from w w w . ja v a 2s .c om*/ else if (dt == Types.TIMESTAMP) checkers.add(TIMESTAMP_COLUMN); else checkers.add(REGULAR_COLUMN); } return checkers; }
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. */// w w w . j av a 2 s . c om 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.metaobj.shared.model.impl.HibernateSchemaNode.java
public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException { if (value == null) { st.setNull(index, Types.VARBINARY); } else {// w w w.j a v a 2s. c o m SchemaNode schemaNode = (SchemaNode) value; Document doc = schemaNode.getSchemaElement().getDocument(); ByteArrayOutputStream out = new ByteArrayOutputStream(); XMLOutputter xmlOutputter = new XMLOutputter(); try { xmlOutputter.output(doc, out); } catch (IOException e) { throw new HibernateException(e); } st.setBytes(index, out.toByteArray()); } }
From source file:org.apache.kylin.jdbc.KylinClient.java
@SuppressWarnings("rawtypes") public static Class convertType(int sqlType) { Class result = Object.class; switch (sqlType) { case Types.CHAR: case Types.VARCHAR: case Types.LONGVARCHAR: result = String.class; break;/*ww w .ja va2 s . c o m*/ case Types.NUMERIC: case Types.DECIMAL: result = BigDecimal.class; break; case Types.BIT: result = Boolean.class; break; case Types.TINYINT: result = Byte.class; break; case Types.SMALLINT: result = Short.class; break; case Types.INTEGER: result = Integer.class; break; case Types.BIGINT: result = Long.class; break; case Types.REAL: case Types.FLOAT: case Types.DOUBLE: result = Double.class; break; case Types.BINARY: case Types.VARBINARY: case Types.LONGVARBINARY: result = Byte[].class; break; case Types.DATE: result = Date.class; break; case Types.TIME: result = Time.class; break; case Types.TIMESTAMP: result = Timestamp.class; break; default: //do nothing break; } return result; }
From source file:org.jumpmind.db.platform.h2.H2DdlBuilder.java
public H2DdlBuilder() { super(DatabaseNamesConstants.H2); databaseInfo.setNonPKIdentityColumnsSupported(false); databaseInfo.setIdentityOverrideAllowed(false); databaseInfo.setSystemForeignKeyIndicesAlwaysNonUnique(true); databaseInfo.setNullAsDefaultValueRequired(false); databaseInfo.addNativeTypeMapping(Types.ARRAY, "BINARY", Types.BINARY); databaseInfo.addNativeTypeMapping(Types.DISTINCT, "BINARY", Types.BINARY); databaseInfo.addNativeTypeMapping(Types.NULL, "BINARY", Types.BINARY); databaseInfo.addNativeTypeMapping(Types.REF, "BINARY", Types.BINARY); databaseInfo.addNativeTypeMapping(Types.STRUCT, "BINARY", Types.BINARY); databaseInfo.addNativeTypeMapping(Types.DATALINK, "BINARY", Types.BINARY); databaseInfo.addNativeTypeMapping(Types.BIT, "BOOLEAN", Types.BIT); databaseInfo.addNativeTypeMapping(Types.NUMERIC, "DECIMAL", Types.DECIMAL); databaseInfo.addNativeTypeMapping(Types.BINARY, "BINARY", Types.BINARY); databaseInfo.addNativeTypeMapping(Types.BLOB, "BLOB", Types.BLOB); databaseInfo.addNativeTypeMapping(Types.CLOB, "CLOB", Types.CLOB); databaseInfo.addNativeTypeMapping(Types.LONGVARCHAR, "VARCHAR(" + Integer.MAX_VALUE + ")", Types.VARCHAR); databaseInfo.addNativeTypeMapping(Types.FLOAT, "DOUBLE", Types.DOUBLE); databaseInfo.addNativeTypeMapping(Types.JAVA_OBJECT, "OTHER"); databaseInfo.setDefaultSize(Types.CHAR, Integer.MAX_VALUE); databaseInfo.setDefaultSize(Types.VARCHAR, Integer.MAX_VALUE); databaseInfo.setDefaultSize(Types.BINARY, Integer.MAX_VALUE); databaseInfo.setDefaultSize(Types.VARBINARY, Integer.MAX_VALUE); databaseInfo.setNonBlankCharColumnSpacePadded(false); databaseInfo.setBlankCharColumnSpacePadded(false); databaseInfo.setCharColumnSpaceTrimmed(true); databaseInfo.setEmptyStringNulled(false); databaseInfo.setNullAsDefaultValueRequired(true); }
From source file:org.theospi.portfolio.presentation.model.impl.HibernatePresentationProperties.java
public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException { if (value == null) { st.setNull(index, Types.VARBINARY); } else {/*from w w w .j av a 2s. c o m*/ ElementBean elementBean = (ElementBean) value; Document doc = new Document(); Element rootElement = elementBean.getBaseElement(); rootElement.detach(); doc.setRootElement(rootElement); ByteArrayOutputStream out = new ByteArrayOutputStream(); XMLOutputter xmlOutputter = new XMLOutputter(); try { xmlOutputter.output(doc, out); } catch (IOException e) { throw new HibernateException(e); } st.setBytes(index, out.toByteArray()); } }