List of usage examples for java.sql Types CLOB
int CLOB
To view the source code for java.sql Types CLOB.
Click Source Link
CLOB
. From source file:com.adaptris.core.services.jdbc.types.ClobColumnTranslatorTest.java
@Test public void testClobToString() throws Exception { Clob clob = new SerialClob("SomeData".toCharArray()); JdbcResultRow row = new JdbcResultRow(); row.setFieldValue("testField", clob, Types.CLOB); String translated = translator.translate(row, 0); assertEquals("SomeData", translated); }
From source file:org.andromda.persistence.hibernate.usertypes.HibernateStringClobType.java
/** * @see org.hibernate.type.NullableType#sqlType() */ public int sqlType() { return Types.CLOB; }
From source file:com.cloudera.sqoop.hive.HiveTypes.java
/** * Given JDBC SQL types coming from another database, what is the best * mapping to a Hive-specific type?/*from w w w . j a v a 2 s . c o m*/ */ public static String toHiveType(int sqlType) { if (sqlType == Types.INTEGER) { return "INT"; } else if (sqlType == Types.VARCHAR) { return "STRING"; } else if (sqlType == Types.CHAR) { return "STRING"; } else if (sqlType == Types.LONGVARCHAR) { return "STRING"; } else if (sqlType == Types.NUMERIC) { // Per suggestion on hive-user, this is converted to DOUBLE for now. return "DOUBLE"; } else if (sqlType == Types.DECIMAL) { // Per suggestion on hive-user, this is converted to DOUBLE for now. return "DOUBLE"; } else if (sqlType == Types.BIT) { return "BOOLEAN"; } else if (sqlType == Types.BOOLEAN) { return "BOOLEAN"; } else if (sqlType == Types.TINYINT) { return "TINYINT"; } else if (sqlType == Types.SMALLINT) { return "INT"; } else if (sqlType == Types.BIGINT) { return "BIGINT"; } else if (sqlType == Types.REAL) { return "DOUBLE"; } else if (sqlType == Types.FLOAT) { return "DOUBLE"; } else if (sqlType == Types.DOUBLE) { return "DOUBLE"; } else if (sqlType == Types.DATE) { // unfortunate type coercion return "STRING"; } else if (sqlType == Types.TIME) { // unfortunate type coercion return "STRING"; } else if (sqlType == Types.TIMESTAMP) { // unfortunate type coercion return "STRING"; } else if (sqlType == Types.CLOB) { return "STRING"; } else { // TODO(aaron): Support BINARY, VARBINARY, LONGVARBINARY, DISTINCT, // BLOB, ARRAY, STRUCT, REF, JAVA_OBJECT. return null; } }
From source file:org.apache.openjpa.jdbc.schema.Schemas.java
/** * Return the SQL type name for the given {@link Types} constant. *//* w ww. j a v a 2s . c om*/ 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.adaptris.core.services.jdbc.types.ClobColumnTranslatorTest.java
@Test public void testClobToStringColumnName() throws Exception { Clob clob = new SerialClob("SomeData".toCharArray()); JdbcResultRow row = new JdbcResultRow(); row.setFieldValue("testField", clob, Types.CLOB); String translated = translator.translate(row, "testField"); assertEquals("SomeData", translated); }
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); }//from w ww .j av a 2s. 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.sakaiproject.mailarchive.impl.conversion.ExtractXMLToColumns.java
public Object getSource(String id, ResultSet rs) throws SQLException { ResultSetMetaData metadata = rs.getMetaData(); String rv = null;//from w w w .j av a 2s . 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.sakaiproject.content.impl.serialize.impl.conversion.FileSizeResourcesConversionHandler.java
public Object getSource(String id, ResultSet rs) throws SQLException { ResultSetMetaData metadata = rs.getMetaData(); String rv = null;//from www .jav a2 s .co m switch (metadata.getColumnType(1)) { case Types.CLOB: Clob clob = rs.getClob(1); if (clob != null) { rv = clob.getSubString(1L, (int) clob.length()); } break; case Types.LONGVARCHAR: case Types.VARCHAR: rv = rs.getString(1); break; } return rv; }
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 ww w . j a v a 2s .c om 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:com.adaptris.core.services.jdbc.types.ClobColumnTranslatorTest.java
@Test public void testClobIncorrectType() throws Exception { JdbcResultRow row = new JdbcResultRow(); row.setFieldValue("testField", new Integer(999), Types.CLOB); try {/*from w w w . j a v a2s .c o m*/ translator.translate(row, 0); fail(); } catch (Exception ex) { // pass, expected } }