List of usage examples for java.sql Types ARRAY
int ARRAY
To view the source code for java.sql Types ARRAY.
Click Source Link
ARRAY
. 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 ww w. j a v 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:com.adaptris.core.services.jdbc.types.ByteArrayColumnTranslatorTest.java
@Test public void testByteIncorrectObject() throws Exception { JdbcResultRow row = new JdbcResultRow(); row.setFieldValue("testField", new Integer(10), Types.ARRAY); try {/* www.j a va 2 s. c om*/ translator.translate(row, "testField"); fail(); } catch (Exception ex) { //pass, expected } }
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:io.lightlink.types.ArrayConverter.java
@Override public Integer getSQLType() { return Types.ARRAY; }
From source file:com.adaptris.core.services.jdbc.types.ByteArrayColumnTranslatorTest.java
@Test public void testBytesWrite() throws Exception { JdbcResultRow row = new JdbcResultRow(); row.setFieldValue("testField", "SomeData".getBytes(), Types.ARRAY); StringWriter writer = new StringWriter(); try (OutputStream out = new WriterOutputStream(writer)) { translator.write(row, 0, out);//from w w w. ja va 2 s . c o m } String translated = writer.toString(); assertEquals("SomeData", translated); }
From source file:com.trackplus.ddl.GenericStringValueConverter.java
protected String extractColumnValue(ResultSet resultSet, int columnIdx, int jdbcType) throws SQLException, DDLException { String value = resultSet.getString(columnIdx); if (value != null) { switch (jdbcType) { case Types.NUMERIC: case Types.DECIMAL: break; case Types.BIT: case Types.BOOLEAN: case Types.TINYINT: case Types.SMALLINT: case Types.INTEGER: case Types.BIGINT: case Types.REAL: case Types.FLOAT: case Types.DOUBLE: { break; }/*from www .ja v a2 s.c om*/ case Types.CHAR: case Types.VARCHAR: case Types.LONGVARCHAR: case Types.BINARY: case Types.VARBINARY: case Types.TIME: case Types.CLOB: case Types.ARRAY: case Types.REF: { value = "'" + value.replaceAll("'", "''") + "'"; break; } case Types.DATE: case Types.TIMESTAMP: { Date d = resultSet.getDate(columnIdx); Calendar cal = Calendar.getInstance(); cal.setTime(d); int year = cal.get(Calendar.YEAR); if (year < 1900) { throw new DDLException("Invalid date:" + d); } else { value = "'" + value + "'"; } break; } case Types.BLOB: case Types.LONGVARBINARY: { Blob blobValue = resultSet.getBlob(columnIdx); String str = new String(Base64.encodeBase64(blobValue.getBytes(1l, (int) blobValue.length()))); value = "'" + str + "'"; break; } default: break; } } return value; }
From source file:org.apache.ddlutils.platform.postgresql.PostgreSqlPlatform.java
/** * Creates a new platform instance.//from w ww . j a v a 2s .c om */ public PostgreSqlPlatform() { PlatformInfo info = getPlatformInfo(); info.setPrimaryKeyColumnAutomaticallyRequired(true); // this is the default length though it might be changed when building PostgreSQL // in file src/include/postgres_ext.h info.setMaxIdentifierLength(31); info.addNativeTypeMapping(Types.ARRAY, "BYTEA", Types.LONGVARBINARY); info.addNativeTypeMapping(Types.BINARY, "BYTEA", Types.LONGVARBINARY); info.addNativeTypeMapping(Types.BIT, "BOOLEAN"); info.addNativeTypeMapping(Types.BLOB, "BYTEA", Types.LONGVARBINARY); info.addNativeTypeMapping(Types.BOOLEAN, "BOOLEAN", Types.BIT); info.addNativeTypeMapping(Types.CLOB, "TEXT", Types.LONGVARCHAR); info.addNativeTypeMapping(Types.DATALINK, "BYTEA", Types.LONGVARBINARY); info.addNativeTypeMapping(Types.DECIMAL, "NUMERIC", Types.NUMERIC); info.addNativeTypeMapping(Types.DISTINCT, "BYTEA", Types.LONGVARBINARY); info.addNativeTypeMapping(Types.DOUBLE, "DOUBLE PRECISION"); info.addNativeTypeMapping(Types.FLOAT, "DOUBLE PRECISION", Types.DOUBLE); info.addNativeTypeMapping(Types.JAVA_OBJECT, "BYTEA", Types.LONGVARBINARY); info.addNativeTypeMapping(Types.LONGVARBINARY, "BYTEA"); info.addNativeTypeMapping(Types.LONGVARCHAR, "TEXT", Types.LONGVARCHAR); info.addNativeTypeMapping(Types.NULL, "BYTEA", Types.LONGVARBINARY); info.addNativeTypeMapping(Types.OTHER, "BYTEA", Types.LONGVARBINARY); info.addNativeTypeMapping(Types.REF, "BYTEA", Types.LONGVARBINARY); info.addNativeTypeMapping(Types.STRUCT, "BYTEA", Types.LONGVARBINARY); info.addNativeTypeMapping(Types.TINYINT, "SMALLINT", Types.SMALLINT); info.addNativeTypeMapping(Types.VARBINARY, "BYTEA", Types.LONGVARBINARY); info.setDefaultSize(Types.CHAR, 254); info.setDefaultSize(Types.VARCHAR, 254); // no support for specifying the size for these types (because they are mapped // to BYTEA which back-maps to BLOB) info.setHasSize(Types.BINARY, false); info.setHasSize(Types.VARBINARY, false); setSqlBuilder(new PostgreSqlBuilder(this)); setModelReader(new PostgreSqlModelReader(this)); }
From source file:com.adaptris.core.services.jdbc.types.ByteArrayColumnTranslatorTest.java
@Test public void testBytesWrite_ByName() throws Exception { JdbcResultRow row = new JdbcResultRow(); row.setFieldValue("testField", "SomeData".getBytes(), Types.ARRAY); StringWriter writer = new StringWriter(); try (OutputStream out = new WriterOutputStream(writer)) { translator.write(row, "testField", out); }//from w ww.j a v a2 s .co m String translated = writer.toString(); assertEquals("SomeData", translated); }
From source file:com.p5solutions.core.jpa.orm.oracle.ConversionUtilityImpl.java
/** * If oracle blob.// w w w .j a v a 2s . c o m * * @param pb * the pb * @param value * the value * @return the object */ protected Object ifOracleBLOB(ParameterBinder pb, Object value) { // if for some reason the object is already an Oracle oracle.sql.BLOB if (value instanceof BLOB) { BLOB blob = (BLOB) value; // simple, if the target and source are the same if (Types.BLOB == getSqlType(pb)) { return blob; } // if the destination is an array? not sure why this would happen // unless the data model changed during runtime?? return byte array. if (Types.ARRAY == getSqlType(pb)) { try { return blob.getBytes(); } catch (Exception e) { logger.error("Unable to get bytes for when working with " + blob); } } // if the object is of type BLOB but the destination is something else, // such as a TIMESTAMP, then its incompatible. logger.warn("*** Incompatible value passed of type " + BLOB.class + ", when the target is expecting [sql-type: " + getSqlType(pb) + "]. Please check " + pb.getEntityClass() + " on paramater " + pb.getBindingPath() + " column name " + pb.getColumnNameUpper()); } return null; }
From source file:org.apache.openjpa.jdbc.schema.Schemas.java
/** * Return the {@link Types} constant for the given SQL type name. *//* w w w.j av a 2 s .c om*/ public static int getJDBCType(String name) { if ("array".equalsIgnoreCase(name)) return Types.ARRAY; if ("bigint".equalsIgnoreCase(name)) return Types.BIGINT; if ("binary".equalsIgnoreCase(name)) return Types.BINARY; if ("bit".equalsIgnoreCase(name)) return Types.BIT; if ("blob".equalsIgnoreCase(name)) return Types.BLOB; if ("char".equalsIgnoreCase(name)) return Types.CHAR; if ("clob".equalsIgnoreCase(name)) return Types.CLOB; if ("date".equalsIgnoreCase(name)) return Types.DATE; if ("decimal".equalsIgnoreCase(name)) return Types.DECIMAL; if ("distinct".equalsIgnoreCase(name)) return Types.DISTINCT; if ("double".equalsIgnoreCase(name)) return Types.DOUBLE; if ("float".equalsIgnoreCase(name)) return Types.FLOAT; if ("integer".equalsIgnoreCase(name)) return Types.INTEGER; if ("java_object".equalsIgnoreCase(name)) return Types.JAVA_OBJECT; if ("longvarbinary".equalsIgnoreCase(name)) return Types.LONGVARBINARY; if ("longvarchar".equalsIgnoreCase(name)) return Types.LONGVARCHAR; if ("null".equalsIgnoreCase(name)) return Types.NULL; if ("numeric".equalsIgnoreCase(name)) return Types.NUMERIC; if ("other".equalsIgnoreCase(name)) return Types.OTHER; if ("real".equalsIgnoreCase(name)) return Types.REAL; if ("ref".equalsIgnoreCase(name)) return Types.REF; if ("smallint".equalsIgnoreCase(name)) return Types.SMALLINT; if ("struct".equalsIgnoreCase(name)) return Types.STRUCT; if ("time".equalsIgnoreCase(name)) return Types.TIME; if ("timestamp".equalsIgnoreCase(name)) return Types.TIMESTAMP; if ("tinyint".equalsIgnoreCase(name)) return Types.TINYINT; if ("varbinary".equalsIgnoreCase(name)) return Types.VARBINARY; if ("varchar".equalsIgnoreCase(name)) return Types.VARCHAR; if (name == null || name.toLowerCase().startsWith("unknown")) return Types.OTHER; throw new IllegalArgumentException("name = " + name); }