Java Code Examples for java.sql.Types#ROWID
The following examples show how to use
java.sql.Types#ROWID .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OracleColumnMetadataReader.java From virtual-schemas with MIT License | 6 votes |
@Override public DataType mapJdbcType(final JdbcTypeDescription jdbcTypeDescription) { switch (jdbcTypeDescription.getJdbcType()) { case Types.DECIMAL: case Types.NUMERIC: return mapNumericType(jdbcTypeDescription); case ORACLE_TIMESTAMP_WITH_TIME_ZONE: case ORACLE_TIMESTAMP_WITH_LOCAL_TIME_ZONE: return DataType.createTimestamp(false); case Types.NCLOB: case ORACLE_CLOB: case INTERVAL_YEAR_TO_MONTH: case INTERVAL_DAY_TO_SECOND: case ORACLE_BINARY_FLOAT: case ORACLE_BINARY_DOUBLE: case Types.ROWID: return DataType.createMaximumSizeVarChar(DataType.ExaCharset.UTF8); case Types.BLOB: return mapBlobType(); default: return super.mapJdbcType(jdbcTypeDescription); } }
Example 2
Source File: CassandraPreparedStatement.java From cassandra-jdbc-wrapper with Apache License 2.0 | 5 votes |
public void setObject(int parameterIndex, Object object) throws SQLException { int targetType=0; if(object.getClass().equals(java.lang.Long.class)){ targetType = Types.BIGINT; } else if(object.getClass().equals(java.io.ByteArrayInputStream.class)){ targetType = Types.BINARY; } else if(object.getClass().equals(java.lang.String.class)){ targetType = Types.VARCHAR; } else if(object.getClass().equals(java.lang.Boolean.class)){ targetType = Types.BOOLEAN; }else if(object.getClass().equals(java.math.BigDecimal.class)){ targetType = Types.DECIMAL; }else if(object.getClass().equals(java.lang.Double.class)){ targetType = Types.DOUBLE; }else if(object.getClass().equals(java.lang.Float.class)){ targetType = Types.FLOAT; }else if(object.getClass().equals(java.net.Inet4Address.class)){ targetType = Types.OTHER; }else if(object.getClass().equals(java.lang.Integer.class)){ targetType = Types.INTEGER; }else if(object.getClass().equals(java.lang.String.class)){ targetType = Types.VARCHAR; }else if(object.getClass().equals(java.sql.Timestamp.class)){ targetType = Types.TIMESTAMP; }else if(object.getClass().equals(java.util.UUID.class)){ targetType = Types.ROWID; }else{ targetType = Types.OTHER; } setObject(parameterIndex, object, targetType, 0); }
Example 3
Source File: JdbcTypeConverter.java From jaybird with GNU Lesser General Public License v2.1 | 5 votes |
/** * Gets the JDBC type value from {@link java.sql.Types} for the field descriptor. * * @param fieldDescriptor * Field descriptor * @return JDBC type, or {@link Types#OTHER} for unknown types */ public static int toJdbcType(final FieldDescriptor fieldDescriptor) { if (fieldDescriptor.isDbKey()) { return Types.ROWID; } return fromFirebirdToJdbcType(fieldDescriptor.getType(), fieldDescriptor.getSubType(), fieldDescriptor.getScale()); }
Example 4
Source File: TestFBRowIdField.java From jaybird with GNU Lesser General Public License v2.1 | 5 votes |
@Before @Override public void setUp() throws Exception { super.setUp(); rowDescriptorBuilder.setType(ISCConstants.SQL_TEXT); rowDescriptorBuilder.setSubType(ISCConstants.CS_BINARY); rowDescriptorBuilder.setLength(FIELD_LENGTH); fieldDescriptor = rowDescriptorBuilder.toFieldDescriptor(); field = new FBRowIdField(fieldDescriptor, fieldData, Types.ROWID); datatypeCoder = fieldDescriptor.getDatatypeCoder(); }
Example 5
Source File: TypesTranslator.java From sql-layer with GNU Affero General Public License v3.0 | 5 votes |
/** * This does not return null * @throws com.foundationdb.server.error.UnsupportedColumnDataTypeException if an appropriate TClass can't be found * @throws com.foundationdb.server.error.UnsupportedDataTypeException if an appropriate TClass can't be found */ public TClass typeClassForJDBCType(int jdbcType, String schemaName, String tableName, String columnName) { switch (jdbcType) { case Types.BLOB: return AkBlob.INSTANCE; case Types.BOOLEAN: return AkBool.INSTANCE; case Types.ARRAY: case Types.DATALINK: case Types.DISTINCT: case Types.JAVA_OBJECT: case Types.NULL: case Types.OTHER: case Types.REF: case Types.ROWID: case Types.STRUCT: default: if (columnName != null) { throw new UnsupportedColumnDataTypeException(schemaName, tableName, columnName, jdbcTypeName(jdbcType)); } else { throw new UnsupportedDataTypeException(jdbcTypeName(jdbcType)); } } }
Example 6
Source File: AbstractFieldMetaData.java From jaybird with GNU Lesser General Public License v2.1 | 4 votes |
protected final String getFieldClassName(int field) throws SQLException { switch (getFieldType(field)) { case Types.CHAR: case Types.VARCHAR: case Types.LONGVARCHAR: return STRING_CLASS_NAME; case Types.SMALLINT: case Types.INTEGER: return INTEGER_CLASS_NAME; case Types.FLOAT: case Types.DOUBLE: return DOUBLE_CLASS_NAME; case Types.TIMESTAMP: return TIMESTAMP_CLASS_NAME; case Types.BLOB: return BLOB_CLASS_NAME; case Types.CLOB: return CLOB_CLASS_NAME; case Types.BINARY: case Types.VARBINARY: case Types.LONGVARBINARY: return BYTE_ARRAY_CLASS_NAME; case Types.ARRAY: return ARRAY_CLASS_NAME; case Types.BIGINT: return LONG_CLASS_NAME; case Types.TIME: return TIME_CLASS_NAME; case Types.DATE: return SQL_DATE_CLASS_NAME; case Types.TIME_WITH_TIMEZONE: return OFFSET_TIME_CLASS_NAME; case Types.TIMESTAMP_WITH_TIMEZONE: return OFFSET_DATE_TIME_CLASS_NAME; case Types.NUMERIC: case Types.DECIMAL: case JaybirdTypeCodes.DECFLOAT: return BIG_DECIMAL_CLASS_NAME; case Types.BOOLEAN: return BOOLEAN_CLASS_NAME; case Types.NULL: case Types.OTHER: return OBJECT_CLASS_NAME; case Types.ROWID: return ROW_ID_CLASS_NAME; default: throw new FBSQLException("Unknown SQL type.", SQLStateConstants.SQL_STATE_INVALID_PARAM_TYPE); } }
Example 7
Source File: ResultSetRecordSet.java From nifi with Apache License 2.0 | 4 votes |
private static RecordFieldType getFieldType(final int sqlType, final String valueClassName) { switch (sqlType) { case Types.BIGINT: case Types.ROWID: return RecordFieldType.LONG; case Types.BIT: case Types.BOOLEAN: return RecordFieldType.BOOLEAN; case Types.CHAR: return RecordFieldType.CHAR; case Types.DATE: return RecordFieldType.DATE; case Types.NUMERIC: case Types.DECIMAL: return RecordFieldType.DECIMAL; case Types.DOUBLE: case Types.REAL: return RecordFieldType.DOUBLE; case Types.FLOAT: return RecordFieldType.FLOAT; case Types.INTEGER: return RecordFieldType.INT; case Types.SMALLINT: return RecordFieldType.SHORT; case Types.TINYINT: return RecordFieldType.BYTE; case Types.LONGNVARCHAR: case Types.LONGVARCHAR: case Types.NCHAR: case Types.NULL: case Types.NVARCHAR: case Types.VARCHAR: return RecordFieldType.STRING; case Types.OTHER: case Types.JAVA_OBJECT: if (STRING_CLASS_NAME.equals(valueClassName)) { return RecordFieldType.STRING; } if (INT_CLASS_NAME.equals(valueClassName)) { return RecordFieldType.INT; } if (LONG_CLASS_NAME.equals(valueClassName)) { return RecordFieldType.LONG; } if (DATE_CLASS_NAME.equals(valueClassName)) { return RecordFieldType.DATE; } if (FLOAT_CLASS_NAME.equals(valueClassName)) { return RecordFieldType.FLOAT; } if (DOUBLE_CLASS_NAME.equals(valueClassName)) { return RecordFieldType.DOUBLE; } if (BIGDECIMAL_CLASS_NAME.equals(valueClassName)) { return RecordFieldType.DECIMAL; } return RecordFieldType.RECORD; case Types.TIME: case Types.TIME_WITH_TIMEZONE: return RecordFieldType.TIME; case Types.TIMESTAMP: case Types.TIMESTAMP_WITH_TIMEZONE: case -101: // Oracle's TIMESTAMP WITH TIME ZONE case -102: // Oracle's TIMESTAMP WITH LOCAL TIME ZONE return RecordFieldType.TIMESTAMP; } return RecordFieldType.STRING; }
Example 8
Source File: AttributeSetup.java From celerio with Apache License 2.0 | 4 votes |
private MappedType getRawMappedType() { switch (attribute.getJdbcType().getJdbcType()) { case Types.ARRAY: return M_ARRAY; case Types.BIGINT: return M_LONG; case Types.BINARY: return M_BYTES; case Types.BIT: case Types.BOOLEAN: return M_BOOLEAN; case Types.BLOB: return M_BLOB; case Types.CLOB: case Types.NCLOB: case Types.SQLXML: return M_CLOB; case Types.DATALINK: return M_URL; case Types.DATE: return M_UTILDATE; case Types.DISTINCT: case Types.JAVA_OBJECT: return M_OBJECT; case Types.DOUBLE: case Types.FLOAT: return M_DOUBLE; case Types.INTEGER: case Types.SMALLINT: case Types.TINYINT: return M_INTEGER; case Types.LONGVARBINARY: return M_BYTES; case Types.CHAR: case Types.LONGVARCHAR: case Types.VARCHAR: case Types.LONGNVARCHAR: case Types.NCHAR: case Types.NVARCHAR: return M_STRING; case Types.DECIMAL: case Types.NUMERIC: ColumnConfig column = attribute.getColumnConfig(); if (column.getDecimalDigits() > 0) { if (column.getSize() < 11 && column.getDecimalDigits() < 4) { return M_DOUBLE; } else { return M_BIGDECIMAL; } } else { if (column.getSize() == 1 && IS_BOOLEAN_PREFIX.apply(attribute)) { return M_BOOLEAN; } else { if (column.getSize() < 11) { return M_INTEGER; } else if (column.getSize() < 19 || attribute.isInPk() || attribute.isInFk()) { // BIG INTEGER IS NOT // ACCEPTED BY HIBERNATE // FOR PK return M_LONG; } else { return M_BIGINTEGER; } } } case Types.OTHER: return M_OBJECT; case Types.REAL: return M_FLOAT; case Types.REF: return M_REF; case Types.STRUCT: return M_OBJECT; case Types.TIME: case Types.TIMESTAMP: return M_UTILDATE; case Types.VARBINARY: if (attribute.getColumnConfig().getSize() == 1) { return M_BYTE; } else { return M_BYTES; } case Types.ROWID: return M_LONG; default: throw new RuntimeException("Could not retrieve the type of " + this); } }
Example 9
Source File: Converters.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * Get {@link GFXDType} for given JDBC {@link Types}. */ public static GFXDType getThriftSQLType(int jdbcType) { switch (jdbcType) { case Types.ARRAY: return GFXDType.ARRAY; case Types.BIGINT: return GFXDType.BIGINT; case Types.BINARY: return GFXDType.BINARY; case Types.BIT: return GFXDType.BOOLEAN; case Types.BLOB: return GFXDType.BLOB; case Types.BOOLEAN: return GFXDType.BOOLEAN; case Types.CHAR: return GFXDType.CHAR; case Types.CLOB: return GFXDType.CLOB; case Types.DATALINK: return GFXDType.DATALINK; case Types.DATE: return GFXDType.DATE; case Types.DECIMAL: return GFXDType.DECIMAL; case Types.DISTINCT: return GFXDType.DISTINCT; case Types.DOUBLE: return GFXDType.DOUBLE; case Types.FLOAT: return GFXDType.FLOAT; case Types.INTEGER: return GFXDType.INTEGER; case Types.JAVA_OBJECT: return GFXDType.JAVA_OBJECT; case TYPE_JSON_OBJECT: return GFXDType.JSON_OBJECT; case Types.LONGNVARCHAR: return GFXDType.LONGNVARCHAR; case Types.LONGVARBINARY: return GFXDType.LONGVARBINARY; case Types.LONGVARCHAR: return GFXDType.LONGVARCHAR; case Types.NCHAR: return GFXDType.NCHAR; case Types.NCLOB: return GFXDType.NCLOB; case Types.NULL: return GFXDType.NULLTYPE; case Types.NUMERIC: return GFXDType.DECIMAL; case Types.NVARCHAR: return GFXDType.NVARCHAR; case Types.OTHER: return GFXDType.OTHER; case TYPE_PDX_OBJECT: return GFXDType.PDX_OBJECT; case Types.REAL: return GFXDType.REAL; case Types.REF: return GFXDType.REF; case Types.ROWID: return GFXDType.ROWID; case Types.SMALLINT: return GFXDType.SMALLINT; case Types.SQLXML: return GFXDType.SQLXML; case Types.STRUCT: return GFXDType.STRUCT; case Types.TIME: return GFXDType.TIME; case Types.TIMESTAMP: return GFXDType.TIMESTAMP; case Types.TINYINT: return GFXDType.TINYINT; case Types.VARBINARY: return GFXDType.VARBINARY; case Types.VARCHAR: return GFXDType.VARCHAR; default: return GFXDType.OTHER; } }
Example 10
Source File: Converters.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * Get JDBC {@link Types} type for given {@link GFXDType}. */ public static int getJdbcType(GFXDType type) { switch (type) { case ARRAY: return Types.ARRAY; case BIGINT: return Types.BIGINT; case BINARY: return Types.BINARY; case BLOB: return Types.BLOB; case BOOLEAN: return Types.BOOLEAN; case CHAR: return Types.CHAR; case CLOB: return Types.CLOB; case DATALINK: return Types.DATALINK; case DATE: return Types.DATE; case DECIMAL: return Types.DECIMAL; case DISTINCT: return Types.DISTINCT; case DOUBLE: return Types.DOUBLE; case FLOAT: return Types.FLOAT; case INTEGER: return Types.INTEGER; case JAVA_OBJECT: return Types.JAVA_OBJECT; case JSON_OBJECT: return TYPE_JSON_OBJECT; case LONGNVARCHAR: return Types.LONGNVARCHAR; case LONGVARBINARY: return Types.LONGVARBINARY; case LONGVARCHAR: return Types.LONGVARCHAR; case NCHAR: return Types.NCHAR; case NCLOB: return Types.NCLOB; case NULLTYPE: return Types.NULL; case NVARCHAR: return Types.NVARCHAR; case OTHER: return Types.OTHER; case PDX_OBJECT: return TYPE_PDX_OBJECT; case REAL: return Types.REAL; case REF: return Types.REF; case ROWID: return Types.ROWID; case SMALLINT: return Types.SMALLINT; case SQLXML: return Types.SQLXML; case STRUCT: return Types.STRUCT; case TIME: return Types.TIME; case TIMESTAMP: return Types.TIMESTAMP; case TINYINT: return Types.TINYINT; case VARBINARY: return Types.VARBINARY; case VARCHAR: return Types.VARCHAR; default: return Types.OTHER; } }
Example 11
Source File: OracleColumnMetadataReaderTest.java From virtual-schemas with MIT License | 4 votes |
@Test void testMapRowid() { final JdbcTypeDescription typeDescription = new JdbcTypeDescription(Types.ROWID, 0, 0, 0, null); assertThat(this.columnMetadataReader.mapJdbcType(typeDescription), equalTo(createMaximumSizeVarChar(DataType.ExaCharset.UTF8))); }
Example 12
Source File: TypeMapper.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
private static Class mapSQLType( final int t ) { switch ( t ) { 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; } }
Example 13
Source File: Converters.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * Get JDBC {@link Types} type for given {@link GFXDType}. */ public static int getJdbcType(GFXDType type) { switch (type) { case ARRAY: return Types.ARRAY; case BIGINT: return Types.BIGINT; case BINARY: return Types.BINARY; case BLOB: return Types.BLOB; case BOOLEAN: return Types.BOOLEAN; case CHAR: return Types.CHAR; case CLOB: return Types.CLOB; case DATALINK: return Types.DATALINK; case DATE: return Types.DATE; case DECIMAL: return Types.DECIMAL; case DISTINCT: return Types.DISTINCT; case DOUBLE: return Types.DOUBLE; case FLOAT: return Types.FLOAT; case INTEGER: return Types.INTEGER; case JAVA_OBJECT: return Types.JAVA_OBJECT; case JSON_OBJECT: return TYPE_JSON_OBJECT; case LONGNVARCHAR: return Types.LONGNVARCHAR; case LONGVARBINARY: return Types.LONGVARBINARY; case LONGVARCHAR: return Types.LONGVARCHAR; case NCHAR: return Types.NCHAR; case NCLOB: return Types.NCLOB; case NULLTYPE: return Types.NULL; case NVARCHAR: return Types.NVARCHAR; case OTHER: return Types.OTHER; case PDX_OBJECT: return TYPE_PDX_OBJECT; case REAL: return Types.REAL; case REF: return Types.REF; case ROWID: return Types.ROWID; case SMALLINT: return Types.SMALLINT; case SQLXML: return Types.SQLXML; case STRUCT: return Types.STRUCT; case TIME: return Types.TIME; case TIMESTAMP: return Types.TIMESTAMP; case TINYINT: return Types.TINYINT; case VARBINARY: return Types.VARBINARY; case VARCHAR: return Types.VARCHAR; default: return Types.OTHER; } }
Example 14
Source File: DatabaseStatement.java From sndml3 with MIT License | 4 votes |
private static String sqlTypeName(int sqltype) { switch (sqltype) { 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.BOOLEAN: return "BOOLEAN"; case Types.CHAR: return "CHAR"; case Types.CLOB: return "CLOB"; case Types.DATALINK: return "DATALINK"; 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.LONGNVARCHAR: return "LONGNVARCHAR"; case Types.LONGVARBINARY: return "LONGVARBINARY"; case Types.LONGVARCHAR: return "LONGVARCHAR"; case Types.NCHAR: return "NCHAR"; case Types.NCLOB: return "NCLOB"; case Types.NULL: return "NULL"; case Types.NUMERIC: return "NUMERIC"; case Types.NVARCHAR: return "NVARCHAR"; case Types.OTHER: return "OTHER"; case Types.REAL: return "REAL"; case Types.REF: return "REF"; case Types.ROWID: return "ROWID"; case Types.SMALLINT: return "SMALLINT"; case Types.SQLXML: return "SQLXML"; 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 Integer.toString(sqltype); } }
Example 15
Source File: AvaticaSite.java From calcite-avatica with Apache License 2.0 | 4 votes |
/** Similar logic to {@link #setObject}. */ public static Object get(Cursor.Accessor accessor, int targetSqlType, Calendar localCalendar) throws SQLException { switch (targetSqlType) { case Types.CLOB: case Types.DATALINK: case Types.NCLOB: case Types.REF: case Types.SQLXML: throw notImplemented(); case Types.STRUCT: return accessor.getStruct(); case Types.ARRAY: return accessor.getArray(); case Types.BIGINT: final long aLong = accessor.getLong(); if (aLong == 0 && accessor.wasNull()) { return null; } return aLong; case Types.BINARY: case Types.LONGVARBINARY: case Types.VARBINARY: return accessor.getBytes(); case Types.BIT: case Types.BOOLEAN: final boolean aBoolean = accessor.getBoolean(); if (!aBoolean && accessor.wasNull()) { return null; } return aBoolean; case Types.BLOB: return accessor.getBlob(); case Types.DATE: return accessor.getDate(localCalendar); case Types.DECIMAL: case Types.NUMERIC: return accessor.getBigDecimal(); case Types.DISTINCT: throw notImplemented(); case Types.DOUBLE: case Types.FLOAT: // yes really; SQL FLOAT is up to 8 bytes final double aDouble = accessor.getDouble(); if (aDouble == 0 && accessor.wasNull()) { return null; } return aDouble; case Types.INTEGER: final int anInt = accessor.getInt(); if (anInt == 0 && accessor.wasNull()) { return null; } return anInt; case Types.JAVA_OBJECT: case Types.OTHER: return accessor.getObject(); case Types.LONGNVARCHAR: case Types.LONGVARCHAR: case Types.NVARCHAR: case Types.VARCHAR: case Types.CHAR: case Types.NCHAR: return accessor.getString(); case Types.REAL: final float aFloat = accessor.getFloat(); if (aFloat == 0 && accessor.wasNull()) { return null; } return aFloat; case Types.ROWID: throw notImplemented(); case Types.SMALLINT: final short aShort = accessor.getShort(); if (aShort == 0 && accessor.wasNull()) { return null; } return aShort; case Types.TIME: return accessor.getTime(localCalendar); case Types.TIMESTAMP: return accessor.getTimestamp(localCalendar); case Types.TINYINT: final byte aByte = accessor.getByte(); if (aByte == 0 && accessor.wasNull()) { return null; } return aByte; default: throw notImplemented(); } }
Example 16
Source File: AvaticaSite.java From calcite-avatica with Apache License 2.0 | 4 votes |
public void setObject(Object x, int targetSqlType) { if (x == null || Types.NULL == targetSqlType) { setNull(targetSqlType); return; } switch (targetSqlType) { case Types.CLOB: case Types.DATALINK: case Types.NCLOB: case Types.OTHER: case Types.REF: case Types.SQLXML: case Types.STRUCT: throw notImplemented(); case Types.ARRAY: setArray(toArray(x)); break; case Types.BIGINT: setLong(toLong(x)); break; case Types.BINARY: case Types.LONGVARBINARY: case Types.VARBINARY: setBytes(toBytes(x)); break; case Types.BIT: case Types.BOOLEAN: setBoolean(toBoolean(x)); break; case Types.BLOB: if (x instanceof Blob) { setBlob((Blob) x); break; } else if (x instanceof InputStream) { setBlob((InputStream) x); } throw unsupportedCast(x.getClass(), Blob.class); case Types.DATE: setDate(toDate(x), calendar); break; case Types.DECIMAL: case Types.NUMERIC: setBigDecimal(toBigDecimal(x)); break; case Types.DISTINCT: throw notImplemented(); case Types.DOUBLE: case Types.FLOAT: // yes really; SQL FLOAT is up to 8 bytes setDouble(toDouble(x)); break; case Types.INTEGER: setInt(toInt(x)); break; case Types.JAVA_OBJECT: setObject(x); break; case Types.LONGNVARCHAR: case Types.LONGVARCHAR: case Types.NVARCHAR: case Types.VARCHAR: case Types.CHAR: case Types.NCHAR: setString(toString(x)); break; case Types.REAL: setFloat(toFloat(x)); break; case Types.ROWID: if (x instanceof RowId) { setRowId((RowId) x); break; } throw unsupportedCast(x.getClass(), RowId.class); case Types.SMALLINT: setShort(toShort(x)); break; case Types.TIME: setTime(toTime(x), calendar); break; case Types.TIMESTAMP: setTimestamp(toTimestamp(x), calendar); break; case Types.TINYINT: setByte(toByte(x)); break; default: throw notImplemented(); } }
Example 17
Source File: CassandraPreparedStatement.java From cassandra-jdbc-wrapper with Apache License 2.0 | 4 votes |
@SuppressWarnings({ "boxing", "unchecked" }) public final void setObject(int parameterIndex, Object object, int targetSqlType, int scaleOrLength) throws SQLException { checkNotClosed(); checkIndex(parameterIndex); switch(targetSqlType){ case Types.VARCHAR: this.statement.setString(parameterIndex-1, object.toString()); break; case Types.BIGINT: this.statement.setLong(parameterIndex-1, Long.parseLong(object.toString())); break; case Types.BINARY: byte[] array = new byte[((java.io.ByteArrayInputStream)object).available()]; try { ((java.io.ByteArrayInputStream)object).read(array); } catch (IOException e1) { LOG.warn("Exception while setting object of BINARY type", e1); } this.statement.setBytes(parameterIndex-1, (ByteBuffer.wrap((array)))); break; case Types.BOOLEAN: this.statement.setBool(parameterIndex-1, (Boolean)object); break; case Types.CHAR: this.statement.setString(parameterIndex-1, object.toString()); break; case Types.CLOB: this.statement.setString(parameterIndex-1, object.toString()); break; case Types.TIMESTAMP: this.statement.setTimestamp(parameterIndex-1, (Timestamp)object); break; case Types.DECIMAL: this.statement.setDecimal(parameterIndex-1, (BigDecimal)object); break; case Types.DOUBLE: this.statement.setDouble(parameterIndex-1, (Double)object); break; case Types.FLOAT: this.statement.setFloat(parameterIndex-1, (Float)object); break; case Types.INTEGER: try{ this.statement.setInt(parameterIndex-1, (Integer)object); }catch(CodecNotFoundException e){ if(e.getMessage().contains("varint")){ // sucks but works this.statement.setVarint(parameterIndex-1, BigInteger.valueOf(Long.parseLong(object.toString()))); } } break; case Types.DATE: this.statement.setTimestamp(parameterIndex-1, (Date)object); break; case Types.ROWID: this.statement.setUUID(parameterIndex-1, (java.util.UUID)object); break; case Types.OTHER: if(object.getClass().equals(com.datastax.driver.core.TupleValue.class)){ this.statement.setTupleValue(parameterIndex-1, (com.datastax.driver.core.TupleValue) object); } if(object.getClass().equals(java.util.UUID.class)){ this.statement.setUUID(parameterIndex-1, (java.util.UUID) object); } if(object.getClass().equals(java.net.InetAddress.class) || object.getClass().equals(java.net.Inet4Address.class)){ this.statement.setInet(parameterIndex-1, (InetAddress) object); } else if ( List.class.isAssignableFrom(object.getClass())) { this.statement.setList(parameterIndex-1,handleAsList(object.getClass(), object)); } else if ( Set.class.isAssignableFrom(object.getClass())) { this.statement.setSet(parameterIndex-1,handleAsSet(object.getClass(), object)); } else if ( Map.class.isAssignableFrom(object.getClass())) { this.statement.setMap(parameterIndex-1,handleAsMap(object.getClass(), object)); } break; } }
Example 18
Source File: Cursor.java From vertx-sql-client with Apache License 2.0 | 4 votes |
public final Object getObject(int column) { if (isNull(column)) return null; switch (jdbcTypes_[column - 1]) { case Types.BOOLEAN: return get_BOOLEAN(column); case Types.SMALLINT: // See Table 4 in JDBC 1 spec (pg. 932 in jdbc book) // @AGG since this is not JDBC, just return as a short //return Integer.valueOf(get_SMALLINT(column)); return get_SMALLINT(column); case Types.INTEGER: return get_INTEGER(column); case Types.BIGINT: return get_BIGINT(column); case Types.REAL: return get_FLOAT(column); case Types.DOUBLE: return get_DOUBLE(column); case Types.DECIMAL: return get_DECIMAL(column); case Types.DATE: return get_DATE(column); case Types.TIME: return get_TIME(column); case Types.TIMESTAMP: return get_TIMESTAMP(column); case Types.CHAR: return get_CHAR(column); case Types.VARCHAR: case Types.LONGVARCHAR: return get_VARCHAR(column); case ClientTypes.BINARY: return get_CHAR_FOR_BIT_DATA(column); case Types.VARBINARY: case Types.LONGVARBINARY: return get_VARCHAR_FOR_BIT_DATA(column); case Types.JAVA_OBJECT: return get_UDT( column ); case Types.ROWID: return get_ROWID(column); // case Types.BLOB: // return getBlobColumn_(column, agent_, true); // case Types.CLOB: // return getClobColumn_(column, agent_, true); default: throw coercionError("Object type: ", column ); } }
Example 19
Source File: ResultSetTableModel.java From netbeans with Apache License 2.0 | 4 votes |
protected static Class<? extends Object> getTypeClass(DBColumn col) { int colType = col.getJdbcType(); if (colType == Types.BIT && col.getPrecision() <= 1) { colType = Types.BOOLEAN; } switch (colType) { case Types.BOOLEAN: return Boolean.class; case Types.TIME: return Time.class; case Types.DATE: return Date.class; case Types.TIMESTAMP: case DBReadWriteHelper.SQL_TYPE_ORACLE_TIMESTAMP: case DBReadWriteHelper.SQL_TYPE_ORACLE_TIMESTAMP_WITH_TZ: return Timestamp.class; case Types.BIGINT: return BigInteger.class; case Types.DOUBLE: return Double.class; case Types.FLOAT: case Types.REAL: return Float.class; case Types.DECIMAL: case Types.NUMERIC: return BigDecimal.class; case Types.INTEGER: case Types.SMALLINT: case Types.TINYINT: return Long.class; case Types.CHAR: case Types.VARCHAR: case Types.NCHAR: case Types.NVARCHAR: case Types.ROWID: return String.class; case Types.BIT: case Types.BINARY: case Types.VARBINARY: case Types.LONGVARBINARY: case Types.BLOB: return Blob.class; case Types.LONGVARCHAR: case Types.LONGNVARCHAR: case Types.CLOB: case Types.NCLOB: /*NCLOB */ return Clob.class; case Types.OTHER: default: return Object.class; } }
Example 20
Source File: JDBCUtils.java From netbeans with Apache License 2.0 | 4 votes |
/** * Get the SQLType for the given java.sql.Type type. * * @param type the java.sql.Type type specifier * @return SQLType.the SQLType for this java.sql.Type, or null if it's not recognized */ public static SQLType getSQLType(int type) { switch (type) { case Types.BIT: return SQLType.BIT; case Types.TINYINT: return SQLType.TINYINT; case Types.SMALLINT: return SQLType.SMALLINT; case Types.INTEGER: return SQLType.INTEGER; case Types.BIGINT: return SQLType.BIGINT; case Types.FLOAT: return SQLType.FLOAT; case Types.REAL: return SQLType.REAL; case Types.DOUBLE: return SQLType.DOUBLE; case Types.NUMERIC: return SQLType.NUMERIC; case Types.DECIMAL: return SQLType.DECIMAL; case Types.CHAR: return SQLType.CHAR; case Types.VARCHAR: return SQLType.VARCHAR; case Types.LONGVARCHAR: return SQLType.LONGVARCHAR; case Types.DATE: return SQLType.DATE; case Types.TIME: return SQLType.TIME; case Types.TIMESTAMP: return SQLType.TIMESTAMP; case Types.BINARY: return SQLType.BINARY; case Types.VARBINARY: return SQLType.VARBINARY; case Types.LONGVARBINARY: return SQLType.LONGVARBINARY; case Types.NULL: return SQLType.NULL; case Types.OTHER: return SQLType.OTHER; case Types.JAVA_OBJECT: return SQLType.JAVA_OBJECT; case Types.DISTINCT: return SQLType.DISTINCT; case Types.STRUCT: return SQLType.STRUCT; case Types.ARRAY: return SQLType.ARRAY; case Types.BLOB: return SQLType.BLOB; case Types.CLOB: return SQLType.CLOB; case Types.REF: return SQLType.REF; case Types.DATALINK: return SQLType.DATALINK; case Types.BOOLEAN: return SQLType.BOOLEAN; case Types.LONGNVARCHAR: return SQLType.LONGVARCHAR; case Types.NCHAR: return SQLType.CHAR; case Types.NCLOB: return SQLType.CLOB; case Types.NVARCHAR: return SQLType.VARCHAR; case Types.SQLXML: return SQLType.SQLXML; case Types.ROWID: return SQLType.ROWID; default: Logger.getLogger(JDBCUtils.class.getName()).log(Level.WARNING, "Unknown JDBC column type: " + type + ". Returns null."); return null; } }