Package oracle.jdbc

Enum Class OracleType

java.lang.Object
java.lang.Enum<OracleType>
oracle.jdbc.OracleType
All Implemented Interfaces:
Serializable, Comparable<OracleType>, Constable, SQLType

public enum OracleType extends Enum<OracleType> implements 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 Details

    • 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 is OracleTypes.VECTOR.

      Many Java/SQL conversions specified in this section are not applicable to the BINARY dimension type. Only boolean[] and byte[] conversions are supported for the VECTOR_BINARY type.

      Java to SQL Conversions

      Instances of the following classes may be passed to the setObject methods of PreparedStatement and CallableStatement if the target SQL type is specified as OracleType.VECTOR or OracleTypes.VECTOR:

      All conversions listed above are lossless.

      SQL to Java Conversions

      Any of the following classes may be passed to the getObject methods of ResultSet and CallableStatement when OracleTypes.VECTOR is returned by ResultSetMetaData.getColumnType(int) or ParameterMetaData.getParameterType(int):

      Conversions to float[], long[], int[], short[], byte[], SparseFloatArray, and SparseByteArray may lose information as a narrowing conversion is applied to each FLOAT64 value, as if converting a double into the component type of the array class.

      Conversions to long[], int[], short[], byte[], and SparseByteArray may lose information as a narrowing conversion is applied to each FLOAT32 value, as if converting a float into the component type of the array class.

      Conversions to boolean[] map a value of 0 to false and all other values to true.

      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 of Clob which reads the same VARCHAR literal expression that would result from a conversion to String. The returned Clob 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. The double[] conversion is "preferred" only because a double 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 a double. For example, the integer "9" becomes the double "9.0". It is unlikely that any ML model would recognize the double[] 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 a VECTOR object, the VECTOR.getType() method can be used to identify the dimension type of an individual VECTOR. A call to one the various to... 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 in VECTOR(100, INT8).

      The int constant corresponding to this SQLType is OracleTypes.VECTOR_INT8.

      The preferred array class for all conversions is byte[], as a byte 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 of PreparedStatement and CallableStatement if the target SQL type is specified as OracleType.VECTOR_INT8 or OracleTypes.VECTOR_INT8:

      Conversions of double[], float[], long[], int[], short[], SparseDoubleArray, and SparseFloatArray 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 a byte.

      Conversions of byte[] and SparseByteArray do not lose information.

      Conversions of boolean[] map a value of true to 1 and a value of false to 0.

      SQL to Java Conversions

      Any of the following classes may be passed to the getObject methods of ResultSet and CallableStatement when OracleTypes.VECTOR_INT8 is returned by ResultSetMetaData.getColumnType(int) or ParameterMetaData.getParameterType(int):

      Conversions to double[], float[], long[], int[], short[], byte[], SparseDoubleArray, SparseFloatArray, and SparseByteArray do not lose information.

      Conversions to boolean[] map a value of 0 to false, and all other values to true.

      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 of Clob which reads the same VARCHAR literal expression that would result from a conversion to String. The returned Clob 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 in VECTOR(100, FLOAT32).

      The int constant corresponding to this SQLType is OracleTypes.VECTOR_FLOAT32.

      The preferred array class for all conversions is float[], as a float 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 of PreparedStatement and CallableStatement if the target SQL type is specified as OracleType.VECTOR_FLOAT32 or OracleTypes.VECTOR_FLOAT32:

      Conversions of double[] and SparseDoubleArray may lose information as a narrowing conversion is applied to each value of the array, as if converting a double into a float.

      Conversions of long[] and int[] 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 a float.

      Conversions of float[], short[], and byte[], SparseFloatArray, and SparseByteArray do not lose information.

      Conversions of boolean[] map a value of true to 1 and a value of false to 0.

      SQL to Java Conversions

      Any of the following classes may be passed to the getObject methods of ResultSet and CallableStatement when OracleTypes.VECTOR_FLOAT32 is returned by ResultSetMetaData.getColumnType(int) or ParameterMetaData.getParameterType(int):

      Conversions to long[], int[], short[], byte[], and SparseByteArray may lose information as a narrowing conversion is applied to each FLOAT32 value, as if converting a float into the component type of the array.

      Conversions to double[], float[], SparseDoubleArray, and SparseFloatArray do not lose information.

      Conversions to boolean[] map a value of 0 to false, and all other values to true.

      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 of Clob which reads the same VARCHAR literal expression that would result from a conversion to String. The returned Clob 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 in VECTOR(100, FLOAT64).

      The int constant corresponding to this SQLType is OracleTypes.VECTOR_FLOAT64.

      The preferred array class for all conversions is double[], as a double 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 of PreparedStatement and CallableStatement if the target SQL type is specified as OracleType.VECTOR_FLOAT64 or OracleTypes.VECTOR_FLOAT64:

      Conversions of long[] may lose information as a widening conversion is applied to each value of the array, as if converting a long into double.

      Conversions of double[], float[], int[], short[], byte[], SparseDoubleArray, SparseFloatArray, and SparseByteArray do not lose information.

      Conversions of boolean[] map a value of true to 1 and a value of false to 0.

      SQL to Java Conversions

      Any of the following classes may be passed to the getObject methods of ResultSet and CallableStatement when OracleTypes.VECTOR_FLOAT64 is returned by ResultSetMetaData.getColumnType(int) or ParameterMetaData.getParameterType(int):

      Conversions to float[], long[], int[], short[], byte[], SparseFloatArray, and SparseByteArray may lose information as a narrowing conversion is applied to each FLOAT64 value, as if converting a double into the component type of the array.

      Conversions to double[] and SparseDoubleArray do not lose information.

      Conversions to boolean[] map a value of 0 to false, and all other values to true.

      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 of Clob which reads the same VARCHAR literal expression that would result from a conversion to String. The returned Clob 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 in VECTOR(128, BINARY).

      The int constant corresponding to this SQLType is OracleTypes.VECTOR_BINARY.

      The preferred array class for all conversions is byte[], as a byte 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 of PreparedStatement and CallableStatement if the target SQL type is specified as OracleType.VECTOR_BINARY or OracleTypes.VECTOR_BINARY:

      • byte[]
      • boolean[]

      Conversions of byte[] unpack 8 bits from each byte 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 the byte[] multiplied by 8.

      Conversions of boolean[] map a value of true to 1 and a value of false to 0.

      SQL to Java Conversions

      Any of the following classes may be passed to the getObject methods of ResultSet and CallableStatement when OracleTypes.VECTOR_BINARY is returned by ResultSetMetaData.getColumnType(int) or ParameterMetaData.getParameterType(int):

      • byte[]
      • boolean[]
      • String
      • java.sql.Clob

      Conversions to byte[] pack 8 BINARY dimensions into the bits of each byte, in MSB order, such that lowest dimension is stored in the highest bit. The length of the byte[] 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 to false, and a value of 1 to true.

      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 of Clob which reads the same VARCHAR literal expression that would result from a conversion to String. The returned Clob is read-only.

      Since:
      23.5
  • Method Details

    • values

      public static OracleType[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static OracleType valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • toOracleType

      public static OracleType toOracleType(SQLType sqlType) throws SQLException
      Returns the OracleType corresponding to SQLType. If the provided sqlType is an instance of OracleType, this method returns the sqlType object. If the provided sqlType is an instance of JDBCType having a vendor type number equal to the vendor type number of an OracleType, this method returns that corresponding OracleType. Otherwise, if no corresponding OracleType exists for the sqlType, this method throws a SQLException.
      Parameters:
      sqlType - A SQLType. Not null.
      Returns:
      corresponding OracleType
      Throws:
      SQLException - If no OracleType corresponds to sqlType
      Since:
      12.2
    • toOracleType

      public static OracleType toOracleType(int oracleTypesConst) throws SQLException
      Returns the OracleType corresponding to the int constant defined in OracleTypes.
      Parameters:
      oracleTypesConst - an int value defined in OracleTypes.
      Returns:
      the corresponding OracleType. Not null.
      Throws:
      SQLException - if there is no corresponding OracleType.
    • getName

      public String getName()
      Specified by:
      getName in interface SQLType
    • getVendor

      public String getVendor()
      Specified by:
      getVendor in interface SQLType
    • getVendorTypeNumber

      public Integer getVendorTypeNumber()
      Specified by:
      getVendorTypeNumber in interface 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