List of usage examples for java.sql Types BLOB
int BLOB
To view the source code for java.sql Types BLOB.
Click Source Link
BLOB
. 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 ww. ja v a 2 s. c o m System.out.println("Outputting string for unknown Type: " + jdbcDataType); return "string"; }
From source file:com.espertech.esperio.db.core.DBUtil.java
/** * Returns the object value for a given column and type. * @param rs result set/*from w w w .j a va 2 s .c o m*/ * @param index column index * @param valueType value type * @return object value * @throws java.sql.SQLException if the column could not be read */ public static Object getValue(ResultSet rs, int index, int valueType) throws SQLException { if (valueType == Types.INTEGER) { return rs.getInt(index); } else if (valueType == Types.BIGINT) { return rs.getLong(index); } else if (valueType == Types.BLOB) { Blob blob = rs.getBlob(index); return getBlobValue(blob); } return rs.getObject(index); }
From source file:org.pentaho.reporting.engine.classic.core.modules.misc.tablemodel.TypeMapper.java
private static Class mapSQLType(final int t) { switch (t) {/*www. j a v a 2s.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:com.siemens.scr.avt.ad.hibernate.BinaryBlobType.java
public int[] sqlTypes() { return new int[] { Types.BLOB }; }
From source file:org.georepublic.db.utils.ResultSetConverter.java
public static JSONArray convert(ResultSet rs) throws SQLException, JSONException { JSONArray json = new JSONArray(); ResultSetMetaData rsmd = rs.getMetaData(); while (rs.next()) { int numColumns = rsmd.getColumnCount(); JSONObject obj = new JSONObject(); for (int i = 1; i < numColumns + 1; i++) { String column_name = rsmd.getColumnName(i); if (rsmd.getColumnType(i) == java.sql.Types.ARRAY) { obj.put(column_name, rs.getArray(column_name)); } else if (rsmd.getColumnType(i) == java.sql.Types.BIGINT) { obj.put(column_name, rs.getInt(column_name)); } else if (rsmd.getColumnType(i) == java.sql.Types.BOOLEAN) { obj.put(column_name, rs.getBoolean(column_name)); } else if (rsmd.getColumnType(i) == java.sql.Types.BLOB) { obj.put(column_name, rs.getBlob(column_name)); } else if (rsmd.getColumnType(i) == java.sql.Types.DOUBLE) { obj.put(column_name, rs.getDouble(column_name)); } else if (rsmd.getColumnType(i) == java.sql.Types.FLOAT) { obj.put(column_name, rs.getFloat(column_name)); } else if (rsmd.getColumnType(i) == java.sql.Types.INTEGER) { obj.put(column_name, rs.getInt(column_name)); } else if (rsmd.getColumnType(i) == java.sql.Types.NVARCHAR) { obj.put(column_name, rs.getNString(column_name)); } else if (rsmd.getColumnType(i) == java.sql.Types.VARCHAR) { obj.put(column_name, rs.getString(column_name)); } else if (rsmd.getColumnType(i) == java.sql.Types.TINYINT) { obj.put(column_name, rs.getInt(column_name)); } else if (rsmd.getColumnType(i) == java.sql.Types.SMALLINT) { obj.put(column_name, rs.getInt(column_name)); } else if (rsmd.getColumnType(i) == java.sql.Types.DATE) { obj.put(column_name, rs.getDate(column_name)); } else if (rsmd.getColumnType(i) == java.sql.Types.TIMESTAMP) { obj.put(column_name, rs.getTimestamp(column_name)); } else { obj.put(column_name, rs.getObject(column_name)); }/*from w ww .j a v a2 s . com*/ } json.put(obj); } return json; }
From source file:org.ambraproject.hibernate.OTMBlobType.java
public int[] sqlTypes() { int[] types = new int[1]; types[0] = Types.BLOB; return types; }
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 ww . j a v a 2s.c o 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:com.adaptris.core.services.jdbc.types.BlobColumnTranslatorTest.java
@Test public void testBlobToString_WithEncoding() throws Exception { BlobColumnTranslator translator = new BlobColumnTranslator("UTF-8"); TestBlob blob = new TestBlob(); String myData = new String("SomeData"); blob.setBytes(0, myData.getBytes("UTF-8")); JdbcResultRow row = new JdbcResultRow(); row.setFieldValue("testField", blob, Types.BLOB); String translated = translator.translate(row, 0); assertEquals("SomeData", translated); }
From source file:org.apache.openjpa.jdbc.schema.Schemas.java
/** * Return the SQL type name for the given {@link Types} constant. *//* w ww . j av 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:org.tsm.concharto.model.geometry.GeometryUserType.java
/** * Return the SQL type codes for the columns mapped by this type. The codes * are defined on <tt>java.sql.Types</tt>. * // w w w . j av a 2 s .c om * @see java.sql.Types * @return int[] the typecodes */ public int[] sqlTypes() { return new int[] { Types.BLOB }; }