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.String
getName()
java.lang.String
getVendor()
java.lang.Integer
getVendorTypeNumber()
boolean
isNationalCharacterSet()
Does this type use the national character set?boolean
isSupported()
Does this driver support this database type?static OracleType
toOracleType(int oracleTypesConst)
Returns the OracleType corresponding to the int constant defined inOracleTypes
.static OracleType
toOracleType(java.sql.SQLType sqlType)
Returns the OracleType corresponding to SQLType.static OracleType
valueOf(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
SQLType
isOracleTypes.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_BINARY
type.Java to SQL Conversions
Instances of the following classes may be passed to the
setObject
methods ofPreparedStatement
andCallableStatement
if the target SQL type is specified asOracleType.VECTOR
orOracleTypes.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
getObject
methods ofResultSet
andCallableStatement
whenOracleTypes.VECTOR
is 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
, andSparseByteArray
may lose information as a narrowing conversion is applied to each FLOAT64 value, as if converting adouble
into the component type of the array class.Conversions to
long[]
,int[]
,short[]
,byte[]
, andSparseByteArray
may lose information as a narrowing conversion is applied to each FLOAT32 value, as if converting afloat
into the component type of the array class.Conversions to
boolean[]
map a value of 0 tofalse
and all other values totrue
.Conversions to
String
return 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
Clob
return an instance ofClob
which reads the same VARCHAR literal expression that would result from a conversion toString
. The returnedClob
is 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 adouble
can 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
double
values. 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
VECTOR
class when a SQL operation may result in VECTOR data of non-uniform dimension types. When VECTOR data is converted into aVECTOR
object, 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
INT8
as its dimension type, as inVECTOR(100, INT8)
.The int constant corresponding to this
SQLType
isOracleTypes.VECTOR_INT8
.The preferred array class for all conversions is
byte[]
, as abyte
can 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
setObject
methods ofPreparedStatement
andCallableStatement
if the target SQL type is specified asOracleType.VECTOR_INT8
orOracleTypes.VECTOR_INT8
:-
double[]
-
float[]
-
long[]
-
int[]
-
short[]
-
byte[]
-
boolean[]
-
VECTOR.SparseDoubleArray
-
VECTOR.SparseFloatArray
-
VECTOR.SparseByteArray
Conversions of
double[]
,float[]
,long[]
,int[]
,short[]
,SparseDoubleArray
, andSparseFloatArray
may 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[]
andSparseByteArray
do not lose information.Conversions of
boolean[]
map a value oftrue
to 1 and a value offalse
to 0.SQL to Java Conversions
Any of the following classes may be passed to the
getObject
methods ofResultSet
andCallableStatement
whenOracleTypes.VECTOR_INT8
is 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
, andSparseByteArray
do not lose information.Conversions to
boolean[]
map a value of 0 tofalse
, and all other values totrue
.Conversions to
String
return 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
Clob
return an instance ofClob
which reads the same VARCHAR literal expression that would result from a conversion toString
. The returnedClob
is 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
FLOAT32
as its dimension type, as inVECTOR(100, FLOAT32)
.The int constant corresponding to this
SQLType
isOracleTypes.VECTOR_FLOAT32
.The preferred array class for all conversions is
float[]
, as afloat
can 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
setObject
methods ofPreparedStatement
andCallableStatement
if the target SQL type is specified asOracleType.VECTOR_FLOAT32
orOracleTypes.VECTOR_FLOAT32
:-
double[]
-
float[]
-
long[]
-
int[]
-
short[]
-
byte[]
-
boolean[]
-
VECTOR.SparseDoubleArray
-
VECTOR.SparseFloatArray
-
VECTOR.SparseByteArray
Conversions of
double[]
andSparseDoubleArray
may lose information as a narrowing conversion is applied to each value of the array, as if converting adouble
into 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
, andSparseByteArray
do not lose information.Conversions of
boolean[]
map a value oftrue
to 1 and a value offalse
to 0.SQL to Java Conversions
Any of the following classes may be passed to the
getObject
methods ofResultSet
andCallableStatement
whenOracleTypes.VECTOR_FLOAT32
is 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[]
, andSparseByteArray
may lose information as a narrowing conversion is applied to each FLOAT32 value, as if converting afloat
into the component type of the array.Conversions to
double[]
,float[]
,SparseDoubleArray
, andSparseFloatArray
do not lose information.Conversions to
boolean[]
map a value of 0 tofalse
, and all other values totrue
.Conversions to
String
return 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
Clob
return an instance ofClob
which reads the same VARCHAR literal expression that would result from a conversion toString
. The returnedClob
is 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
FLOAT64
as its dimension type, as inVECTOR(100, FLOAT64)
.The int constant corresponding to this
SQLType
isOracleTypes.VECTOR_FLOAT64
.The preferred array class for all conversions is
double[]
, as adouble
can 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
setObject
methods ofPreparedStatement
andCallableStatement
if the target SQL type is specified asOracleType.VECTOR_FLOAT64
orOracleTypes.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 along
intodouble
.Conversions of
double[]
,float[]
,int[]
,short[]
,byte[]
,SparseDoubleArray
,SparseFloatArray
, andSparseByteArray
do not lose information.Conversions of
boolean[]
map a value oftrue
to 1 and a value offalse
to 0.SQL to Java Conversions
Any of the following classes may be passed to the
getObject
methods ofResultSet
andCallableStatement
whenOracleTypes.VECTOR_FLOAT64
is 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
, andSparseByteArray
may lose information as a narrowing conversion is applied to each FLOAT64 value, as if converting adouble
into the component type of the array.Conversions to
double[]
andSparseDoubleArray
do not lose information.Conversions to
boolean[]
map a value of 0 tofalse
, and all other values totrue
.Conversions to
String
return 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
Clob
return an instance ofClob
which reads the same VARCHAR literal expression that would result from a conversion toString
. The returnedClob
is 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
BINARY
as its dimension type, as inVECTOR(128, BINARY)
.The int constant corresponding to this
SQLType
isOracleTypes.VECTOR_BINARY
.The preferred array class for all conversions is
byte[]
, as abyte
can 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
setObject
methods ofPreparedStatement
andCallableStatement
if the target SQL type is specified asOracleType.VECTOR_BINARY
orOracleTypes.VECTOR_BINARY
:-
byte[]
-
boolean[]
Conversions of
byte[]
unpack 8 bits from eachbyte
in 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 oftrue
to 1 and a value offalse
to 0.SQL to Java Conversions
Any of the following classes may be passed to the
getObject
methods ofResultSet
andCallableStatement
whenOracleTypes.VECTOR_BINARY
is 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
String
return 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
Clob
return an instance ofClob
which reads the same VARCHAR literal expression that would result from a conversion toString
. The returnedClob
is 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 providedsqlType
is an instance ofOracleType
, this method returns thesqlType
object. If the providedsqlType
is an instance ofJDBCType
having a vendor type number equal to the vendor type number of anOracleType
, this method returns that correspondingOracleType
. Otherwise, if no correspondingOracleType
exists for thesqlType
, this method throws aSQLException
.- Parameters:
sqlType
- A SQLType. Not null.- Returns:
- corresponding OracleType
- Throws:
java.sql.SQLException
- If no OracleType corresponds tosqlType
-
-