Enum OracleType
- java.lang.Object
-
- java.lang.Enum<OracleType>
-
- oracle.jdbc.OracleType
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<OracleType>,java.sql.SQLType
public enum OracleType extends java.lang.Enum<OracleType> implements java.sql.SQLType
An enumeration of types documented in Oracle Database SQL Language Reference 21c Release 1. The JDBC driver does not necessarily support every type.- Since:
- 12.1
-
-
Enum Constant Summary
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetName()java.lang.StringgetVendor()java.lang.IntegergetVendorTypeNumber()booleanisNationalCharacterSet()Does this type use the national character set?booleanisSupported()Does this driver support this database type?static OracleTypetoOracleType(int oracleTypesConst)Returns the OracleType corresponding to the int constant defined inOracleTypes.static OracleTypetoOracleType(java.sql.SQLType sqlType)Returns the OracleType corresponding to SQLType.static OracleTypevalueOf(java.lang.String name)Returns the enum constant of this type with the specified name.static OracleType[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
VARCHAR2
public static final OracleType VARCHAR2
-
NVARCHAR
public static final OracleType NVARCHAR
-
NUMBER
public static final OracleType NUMBER
-
FLOAT
public static final OracleType FLOAT
-
LONG
public static final OracleType LONG
-
DATE
public static final OracleType DATE
-
BINARY_FLOAT
public static final OracleType BINARY_FLOAT
-
BINARY_DOUBLE
public static final OracleType BINARY_DOUBLE
-
TIMESTAMP
public static final OracleType TIMESTAMP
-
TIMESTAMP_WITH_TIME_ZONE
public static final OracleType TIMESTAMP_WITH_TIME_ZONE
-
TIMESTAMP_WITH_LOCAL_TIME_ZONE
public static final OracleType TIMESTAMP_WITH_LOCAL_TIME_ZONE
-
INTERVAL_YEAR_TO_MONTH
public static final OracleType INTERVAL_YEAR_TO_MONTH
-
INTERVAL_DAY_TO_SECOND
public static final OracleType INTERVAL_DAY_TO_SECOND
-
PLSQL_BOOLEAN
public static final OracleType PLSQL_BOOLEAN
PLSQL_BOOLEAN binds BOOLEAN type for input/output parameters when executing a PLSQL function/procedure. Only available for thin driver.- Since:
- 12.2
-
RAW
public static final OracleType RAW
-
LONG_RAW
public static final OracleType LONG_RAW
-
ROWID
public static final OracleType ROWID
-
UROWID
public static final OracleType UROWID
-
CHAR
public static final OracleType CHAR
-
NCHAR
public static final OracleType NCHAR
-
CLOB
public static final OracleType CLOB
-
NCLOB
public static final OracleType NCLOB
-
BLOB
public static final OracleType BLOB
-
BFILE
public static final OracleType BFILE
-
JSON
public static final OracleType JSON
-
BOOLEAN
public static final OracleType BOOLEAN
-
OBJECT
public static final OracleType OBJECT
-
REF
public static final OracleType REF
-
VARRAY
public static final OracleType VARRAY
-
NESTED_TABLE
public static final OracleType NESTED_TABLE
-
ANYTYPE
public static final OracleType ANYTYPE
-
ANYDATA
public static final OracleType ANYDATA
-
ANYDATASET
public static final OracleType ANYDATASET
-
XMLTYPE
public static final OracleType XMLTYPE
-
HTTPURITYPE
public static final OracleType HTTPURITYPE
-
XDBURITYPE
public static final OracleType XDBURITYPE
-
DBURITYPE
public static final OracleType DBURITYPE
-
SDO_GEOMETRY
public static final OracleType SDO_GEOMETRY
-
SDO_TOPO_GEOMETRY
public static final OracleType SDO_TOPO_GEOMETRY
-
SDO_GEORASTER
public static final OracleType SDO_GEORASTER
-
ORDAUDIO
public static final OracleType ORDAUDIO
-
ORDDICOM
public static final OracleType ORDDICOM
-
ORDDOC
public static final OracleType ORDDOC
-
ORDIMAGE
public static final OracleType ORDIMAGE
-
ORDVIDEO
public static final OracleType ORDVIDEO
-
SI_AVERAGE_COLOR
public static final OracleType SI_AVERAGE_COLOR
-
SI_COLOR
public static final OracleType SI_COLOR
-
SI_COLOR_HISTOGRAM
public static final OracleType SI_COLOR_HISTOGRAM
-
SI_FEATURE_LIST
public static final OracleType SI_FEATURE_LIST
-
SI_POSITIONAL_COLOR
public static final OracleType SI_POSITIONAL_COLOR
-
SI_STILL_IMAGE
public static final OracleType SI_STILL_IMAGE
-
SI_TEXTURE
public static final OracleType SI_TEXTURE
-
VECTOR
public static final OracleType VECTOR
A VECTOR that may contain any dimension type: FLOAT64, FLOAT32, INT8, or BINARY. This type represents a VECTOR declared with "*" as its dimension type, as in "VECTOR(100, *)"
The int constant corresponding to this
SQLTypeisOracleTypes.VECTOR.Many Java/SQL conversions specified in this section are not applicable to the BINARY dimension type. Only
boolean[]andbyte[]conversions are supported for theVECTOR_BINARYtype.Java to SQL Conversions
Instances of the following classes may be passed to the
setObjectmethods ofPreparedStatementandCallableStatementif the target SQL type is specified asOracleType.VECTORorOracleTypes.VECTOR:-
double[]is converted to a VECTOR of DENSE FLOAT64 dimensions. -
float[]is converted to a VECTOR of DENSE FLOAT32 dimensions. -
byte[]is converted to a VECTOR of DENSE INT8 dimensions. -
boolean[]is converted to a VECTOR of (DENSE) BINARY dimensions. -
is converted to a VECTOR of SPARSE FLOAT64 dimensions.VECTOR.SparseDoubleArray -
is converted to a VECTOR of SPARSE FLOAT32 dimensionsVECTOR.SparseFloatArray -
is converted to a VECTOR of SPARSE INT8 dimensionsVECTOR.SparseByteArray
All conversions listed above are lossless.
SQL to Java Conversions
Any of the following classes may be passed to the
getObjectmethods ofResultSetandCallableStatementwhenOracleTypes.VECTORis returned byResultSetMetaData.getColumnType(int)orParameterMetaData.getParameterType(int):-
double[] -
float[] -
long[] -
int[] -
short[] -
byte[] -
boolean[] -
String -
java.sql.Clob -
oracle.sql.VECTOR -
VECTOR.SparseDoubleArray -
VECTOR.SparseFloatArray -
VECTOR.SparseByteArray
Conversions to
float[],long[],int[],short[],byte[],SparseFloatArray, andSparseByteArraymay lose information as a narrowing conversion is applied to each FLOAT64 value, as if converting adoubleinto the component type of the array class.Conversions to
long[],int[],short[],byte[], andSparseByteArraymay lose information as a narrowing conversion is applied to each FLOAT32 value, as if converting afloatinto the component type of the array class.Conversions to
boolean[]map a value of 0 tofalseand all other values totrue.Conversions to
Stringreturn the VARCHAR literal expression of the VECTOR. The String for a DENSE VECTOR expresses the value of each dimension:[value0,value1,...]. The String for a SPARSE VECTOR expresses the total length of dimensions, followed by the indices of dimensions having non-zero values, followed by the non-zero values:[length,[indices],[non-zero-values]].Conversions to
Clobreturn an instance ofClobwhich reads the same VARCHAR literal expression that would result from a conversion toString. The returnedClobis read-only.Guidance on SQL to Java Conversions
The "preferred" array class for SQL to Java conversions is
double[], but this may not be a sensible choice for all dimension types. Thedouble[]conversion is "preferred" only because adoublecan store the value of any dimension type without losing information.An easy problem to see is how memory gets wasted when FLOAT32, INT8, or BINARY dimensions are stored using a 64-bit
double.A more concerning issue arises when JDBC converts integer valued dimensions into
doublevalues. JDBC performs that conversion as if by casting the integer to adouble. For example, the integer "9" becomes the double "9.0". It is unlikely that any ML model would recognize thedouble[]which results from this conversion. Typically, a quantization technique would be used to represent floating point dimensions as integers; This is not what JDBC is doing.Programmers are encouraged to make use of a conversion to the
VECTORclass when a SQL operation may result in VECTOR data of non-uniform dimension types. When VECTOR data is converted into aVECTORobject, theVECTOR.getType()method can be used to identify the dimension type of an individual VECTOR. A call to one the variousto...methods can then convert the VECTOR data into an appropriate format, as shown in this example:void example(ResultSet resultSet) throws SQLException { while (resultSet.next()) { VECTOR vector = resultSet.getObject("vector", VECTOR.class); if (vector == null) continue; switch (vector.getType()) { case VECTOR_FLOAT64: double[] doubles = vector.toDoubleArray(); handleFloat64(doubles); break; case VECTOR_FLOAT32: float[] floats = vector.toFloatArray(); handleFloat32(floats); break; case VECTOR_INT8: byte[] bytes = vector.toByteArray(); handleInt8(bytes); break; case VECTOR_BINARY: byte[] packedBits = vector.toByteArray(); handleBinary(packedBits); break; default: handleUnknown(vector.stringValue()); break; } } }- Since:
- 23.4
-
-
VECTOR_INT8
public static final OracleType VECTOR_INT8
A VECTOR that contains signed 8-bit integers. This type represents a VECTOR declared with
INT8as its dimension type, as inVECTOR(100, INT8).The int constant corresponding to this
SQLTypeisOracleTypes.VECTOR_INT8.The preferred array class for all conversions is
byte[], as abytecan store any INT8 value in the least number of bits without losing information.Java to SQL Conversions
Instances of the following classes may be passed to the
setObjectmethods ofPreparedStatementandCallableStatementif the target SQL type is specified asOracleType.VECTOR_INT8orOracleTypes.VECTOR_INT8:-
double[] -
float[] -
long[] -
int[] -
short[] -
byte[] -
boolean[] -
VECTOR.SparseDoubleArray -
VECTOR.SparseFloatArray -
VECTOR.SparseByteArray
Conversions of
double[],float[],long[],int[],short[],SparseDoubleArray, andSparseFloatArraymay lose information as a narrowing conversion is applied to each value of the array, as if converting the component type of the array into abyte.Conversions of
byte[]andSparseByteArraydo not lose information.Conversions of
boolean[]map a value oftrueto 1 and a value offalseto 0.SQL to Java Conversions
Any of the following classes may be passed to the
getObjectmethods ofResultSetandCallableStatementwhenOracleTypes.VECTOR_INT8is returned byResultSetMetaData.getColumnType(int)orParameterMetaData.getParameterType(int):-
double[] -
float[] -
long[] -
int[] -
short[] -
byte[] -
boolean[] -
String -
java.sql.Clob -
VECTOR.SparseDoubleArray -
VECTOR.SparseFloatArray -
VECTOR.SparseByteArray
Conversions to
double[],float[],long[],int[],short[],byte[],SparseDoubleArray,SparseFloatArray, andSparseByteArraydo not lose information.Conversions to
boolean[]map a value of 0 tofalse, and all other values totrue.Conversions to
Stringreturn the VARCHAR literal expression of the VECTOR. The String for a DENSE VECTOR expresses the value of each dimension:[value0,value1,...]. The String for a SPARSE VECTOR expresses the total length of dimensions, followed by the indices of dimensions having non-zero values, followed by the non-zero values:[length,[indices],[non-zero-values]].Conversions to
Clobreturn an instance ofClobwhich reads the same VARCHAR literal expression that would result from a conversion toString. The returnedClobis read-only.- Since:
- 23.4
-
-
VECTOR_FLOAT32
public static final OracleType VECTOR_FLOAT32
A VECTOR that contains 32-bit floating point numbers. This type represents a VECTOR declared with
FLOAT32as its dimension type, as inVECTOR(100, FLOAT32).The int constant corresponding to this
SQLTypeisOracleTypes.VECTOR_FLOAT32.The preferred array class for all conversions is
float[], as afloatcan store any FLOAT32 value in the least number of bits without losing information.Java to SQL Conversions
Instances of the following classes may be passed to the
setObjectmethods ofPreparedStatementandCallableStatementif the target SQL type is specified asOracleType.VECTOR_FLOAT32orOracleTypes.VECTOR_FLOAT32:-
double[] -
float[] -
long[] -
int[] -
short[] -
byte[] -
boolean[] -
VECTOR.SparseDoubleArray -
VECTOR.SparseFloatArray -
VECTOR.SparseByteArray
Conversions of
double[]andSparseDoubleArraymay lose information as a narrowing conversion is applied to each value of the array, as if converting adoubleinto afloat.Conversions of
long[]andint[]may lose information as a widening conversion is applied to each value of the array, as if converting the component type of the array into afloat.Conversions of
float[],short[], andbyte[],SparseFloatArray, andSparseByteArraydo not lose information.Conversions of
boolean[]map a value oftrueto 1 and a value offalseto 0.SQL to Java Conversions
Any of the following classes may be passed to the
getObjectmethods ofResultSetandCallableStatementwhenOracleTypes.VECTOR_FLOAT32is returned byResultSetMetaData.getColumnType(int)orParameterMetaData.getParameterType(int):-
double[] -
float[] -
long[] -
int[] -
short[] -
byte[] -
boolean[] -
String -
java.sql.Clob -
VECTOR.SparseDoubleArray -
VECTOR.SparseFloatArray -
VECTOR.SparseByteArray
Conversions to
long[],int[],short[],byte[], andSparseByteArraymay lose information as a narrowing conversion is applied to each FLOAT32 value, as if converting afloatinto the component type of the array.Conversions to
double[],float[],SparseDoubleArray, andSparseFloatArraydo not lose information.Conversions to
boolean[]map a value of 0 tofalse, and all other values totrue.Conversions to
Stringreturn the VARCHAR literal expression of the VECTOR. The String for a DENSE VECTOR expresses the value of each dimension:[value0,value1,...]. The String for a SPARSE VECTOR expresses the total length of dimensions, followed by the indices of dimensions having non-zero values, followed by the non-zero values:[length,[indices],[non-zero-values]].Conversions to
Clobreturn an instance ofClobwhich reads the same VARCHAR literal expression that would result from a conversion toString. The returnedClobis read-only.- Since:
- 23.4
-
-
VECTOR_FLOAT64
public static final OracleType VECTOR_FLOAT64
A VECTOR that contains 64-bit floating point numbers. This type represents a VECTOR declared with
FLOAT64as its dimension type, as inVECTOR(100, FLOAT64).The int constant corresponding to this
SQLTypeisOracleTypes.VECTOR_FLOAT64.The preferred array class for all conversions is
double[], as adoublecan store any FLOAT64 value in the least number of bits without losing information.Java to SQL Conversions
Instances of the following classes may be passed to the
setObjectmethods ofPreparedStatementandCallableStatementif the target SQL type is specified asOracleType.VECTOR_FLOAT64orOracleTypes.VECTOR_FLOAT64:-
double[] -
float[] -
long[] -
int[] -
short[] -
byte[] -
boolean[] -
VECTOR.SparseDoubleArray -
VECTOR.SparseFloatArray -
VECTOR.SparseByteArray
Conversions of
long[]may lose information as a widening conversion is applied to each value of the array, as if converting alongintodouble.Conversions of
double[],float[],int[],short[],byte[],SparseDoubleArray,SparseFloatArray, andSparseByteArraydo not lose information.Conversions of
boolean[]map a value oftrueto 1 and a value offalseto 0.SQL to Java Conversions
Any of the following classes may be passed to the
getObjectmethods ofResultSetandCallableStatementwhenOracleTypes.VECTOR_FLOAT64is returned byResultSetMetaData.getColumnType(int)orParameterMetaData.getParameterType(int):-
double[] -
float[] -
long[] -
int[] -
short[] -
byte[] -
boolean[] -
String -
java.sql.Clob -
VECTOR.SparseDoubleArray -
VECTOR.SparseFloatArray -
VECTOR.SparseByteArray
Conversions to
float[],long[],int[],short[],byte[],SparseFloatArray, andSparseByteArraymay lose information as a narrowing conversion is applied to each FLOAT64 value, as if converting adoubleinto the component type of the array.Conversions to
double[]andSparseDoubleArraydo not lose information.Conversions to
boolean[]map a value of 0 tofalse, and all other values totrue.Conversions to
Stringreturn the VARCHAR literal expression of the VECTOR. The String for a DENSE VECTOR expresses the value of each dimension:[value0,value1,...]. The String for a SPARSE VECTOR expresses the total length of dimensions, followed by the indices of dimensions having non-zero values, followed by the non-zero values:[length,[indices],[non-zero-values]].Conversions to
Clobreturn an instance ofClobwhich reads the same VARCHAR literal expression that would result from a conversion toString. The returnedClobis read-only.- Since:
- 23.4
-
-
VECTOR_BINARY
public static final OracleType VECTOR_BINARY
A VECTOR that contains unsigned 8-bit integers, where each bit stores one dimension. This type represents a VECTOR declared with
BINARYas its dimension type, as inVECTOR(128, BINARY).The int constant corresponding to this
SQLTypeisOracleTypes.VECTOR_BINARY.The preferred array class for all conversions is
byte[], as abytecan store 8 BINARY values in the least number of bits without losing information.Java to SQL Conversions
Instances of the following classes may be passed to the
setObjectmethods ofPreparedStatementandCallableStatementif the target SQL type is specified asOracleType.VECTOR_BINARYorOracleTypes.VECTOR_BINARY:-
byte[] -
boolean[]
Conversions of
byte[]unpack 8 bits from eachbytein MSB order, such that the highest bit is stored at a lower dimension within the VECTOR. The number of dimensions in the VECTOR is the length of thebyte[]multiplied by 8.Conversions of
boolean[]map a value oftrueto 1 and a value offalseto 0.SQL to Java Conversions
Any of the following classes may be passed to the
getObjectmethods ofResultSetandCallableStatementwhenOracleTypes.VECTOR_BINARYis returned byResultSetMetaData.getColumnType(int)orParameterMetaData.getParameterType(int):-
byte[] -
boolean[] -
String -
java.sql.Clob
Conversions to
byte[]pack 8 BINARY dimensions into the bits of eachbyte, in MSB order, such that lowest dimension is stored in the highest bit. The length of thebyte[]is the number of dimensions divided by 8, and then plus 1 if the number of dimensions is not evenly divisible by 8.Conversions to
boolean[]map a value of 0 tofalse, and a value of 1 totrue.Conversions to
Stringreturn the VARCHAR literal expression of a BINARY VECTOR. This is a sequence of 8-bit unsigned integers, with each integer storing 8 BINARY values. The integers are separated by a comma and enclosed in square brackets:[value0,value1,...].Conversions to
Clobreturn an instance ofClobwhich reads the same VARCHAR literal expression that would result from a conversion toString. The returnedClobis read-only.- Since:
- 23.5
-
-
-
Method Detail
-
values
public static OracleType[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (OracleType c : OracleType.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static OracleType valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException- if this enum type has no constant with the specified namejava.lang.NullPointerException- if the argument is null
-
toOracleType
public static OracleType toOracleType(java.sql.SQLType sqlType) throws java.sql.SQLException
Returns the OracleType corresponding to SQLType. If the providedsqlTypeis an instance ofOracleType, this method returns thesqlTypeobject. If the providedsqlTypeis an instance ofJDBCTypehaving a vendor type number equal to the vendor type number of anOracleType, this method returns that correspondingOracleType. Otherwise, if no correspondingOracleTypeexists for thesqlType, this method throws aSQLException.- Parameters:
sqlType- A SQLType. Not null.- Returns:
- corresponding OracleType
- Throws:
java.sql.SQLException- If no OracleType corresponds tosqlType- Since:
- 12.2
-
toOracleType
public static OracleType toOracleType(int oracleTypesConst) throws java.sql.SQLException
Returns the OracleType corresponding to the int constant defined inOracleTypes.- Parameters:
oracleTypesConst- an int value defined inOracleTypes.- Returns:
- the corresponding OracleType. Not null.
- Throws:
java.sql.SQLException- if there is no corresponding OracleType.
-
getName
public java.lang.String getName()
- Specified by:
getNamein interfacejava.sql.SQLType
-
getVendor
public java.lang.String getVendor()
- Specified by:
getVendorin interfacejava.sql.SQLType
-
getVendorTypeNumber
public java.lang.Integer getVendorTypeNumber()
- Specified by:
getVendorTypeNumberin interfacejava.sql.SQLType
-
isNationalCharacterSet
public boolean isNationalCharacterSet()
Does this type use the national character set?- Returns:
- true iff this type uses the national character set
- Since:
- 12.2
-
isSupported
public boolean isSupported()
Does this driver support this database type?- Returns:
- true iff this driver supports this database type
- Since:
- 12.2
-
-