org.apache.calcite.avatica

## Enum SqlType

- java.lang.Object
- - java.lang.Enum<SqlType>
  - - org.apache.calcite.avatica.SqlType

All Implemented Interfaces:
  Serializable, Comparable<SqlType>

    public enum SqlType
    extends Enum<SqlType>

Extends the information in `Types`.

The information in the following conversions tables (from the JDBC 4.1 specification) is held in members of this class.

Table B-1: JDBC Types Mapped to Java Types

     JDBC Type     Java Type
     ============= =========================
     CHAR          String
     VARCHAR       String
     LONGVARCHAR   String
     NUMERIC       java.math.BigDecimal
     DECIMAL       java.math.BigDecimal
     BIT           boolean
     BOOLEAN       boolean
     TINYINT       byte
     SMALLINT      short
     INTEGER       int
     BIGINT        long
     REAL          float
     FLOAT         double
     DOUBLE        double
     BINARY        byte[]
     VARBINARY     byte[]
     LONGVARBINARY byte[]
     DATE          java.sql.Date
     TIME          java.sql.Time
     TIMESTAMP     java.sql.Timestamp
     CLOB          java.sql.Clob
     BLOB          java.sql.Blob
     ARRAY         java.sql.Array
     DISTINCT      mapping of underlying type
     STRUCT        java.sql.Struct
     REF           java.sql.Ref
     DATALINK      java.net.URL
     JAVA_OBJECT   underlying Java class
     ROWID         java.sql.RowId
     NCHAR         String
     NVARCHAR      String
     LONGNVARCHAR  String
     NCLOB         java.sql.NClob
     SQLXML        java.sql.SQLXML

Table B-2: Standard Mapping from Java Types to JDBC Types

     Java Type            JDBC Type
     ==================== ==============================================
     String               CHAR, VARCHAR, LONGVARCHAR, NCHAR, NVARCHAR or
                          LONGNVARCHAR
     java.math.BigDecimal NUMERIC
     boolean              BIT or BOOLEAN
     byte                 TINYINT
     short                SMALLINT
     int                  INTEGER
     long                 BIGINT
     float                REAL
     double               DOUBLE
     byte[]               BINARY, VARBINARY, or LONGVARBINARY
     java.sql.Date        DATE
     java.sql.Time        TIME
     java.sql.Timestamp   TIMESTAMP
     java.sql.Clob        CLOB
     java.sql.Blob        BLOB
     java.sql.Array       ARRAY
     java.sql.Struct      STRUCT
     java.sql.Ref         REF
     java.net.URL         DATALINK
     Java class           JAVA_OBJECT
     java.sql.RowId       ROWID
     java.sql.NClob       NCLOB
     java.sql.SQLXML      SQLXML

TABLE B-3: Mapping from JDBC Types to Java Object Types

     JDBC Type     Java Object Type
     ============= ======================
     CHAR          String
     VARCHAR       String
     LONGVARCHAR   String
     NUMERIC       java.math.BigDecimal
     DECIMAL       java.math.BigDecimal
     BIT           Boolean
     BOOLEAN       Boolean
     TINYINT       Integer
     SMALLINT      Integer
     INTEGER       Integer
     BIGINT        Long
     REAL          Float
     FLOAT         Double
     DOUBLE        Double
     BINARY        byte[]
     VARBINARY     byte[]
     LONGVARBINARY byte[]
     DATE          java.sql.Date
     TIME          java.sql.Time
     TIMESTAMP     java.sql.Timestamp
     DISTINCT      Object type of underlying type
     CLOB          java.sql.Clob
     BLOB          java.sql.Blob
     ARRAY         java.sql.Array
     STRUCT        java.sql.Struct or java.sql.SQLData
     REF           java.sql.Ref
     DATALINK      java.net.URL
     JAVA_OBJECT   underlying Java class
     ROWID         java.sql.RowId
     NCHAR         String
     NVARCHAR      String
     LONGNVARCHAR  String
     NCLOB         java.sql.NClob
     SQLXML        java.sql.SQLXML

TABLE B-4: Mapping from Java Object Types to JDBC Types

     Java Object Type     JDBC Type
     ==================== ===========================================
     String               CHAR, VARCHAR, LONGVARCHAR, NCHAR, NVARCHAR
                          or LONGNVARCHAR
     java.math.BigDecimal NUMERIC
     Boolean              BIT or BOOLEAN
     Byte                 TINYINT
     Short                SMALLINT
     Integer              INTEGER
     Long                 BIGINT
     Float                REAL
     Double               DOUBLE
     byte[]               BINARY, VARBINARY, or LONGVARBINARY
     java.math.BigInteger BIGINT
     java.sql.Date        DATE
     java.sql.Time        TIME
     java.sql.Timestamp   TIMESTAMP
     java.sql.Clob        CLOB
     java.sql.Blob        BLOB
     java.sql.Array       ARRAY
     java.sql.Struct      STRUCT
     java.sql.Ref         REF
     java.net.URL         DATALINK
     Java class           JAVA_OBJECT
     java.sql.RowId       ROWID
     java.sql.NClob       NCLOB
     java.sql.SQLXML      SQLXML
     java.util.Calendar   TIMESTAMP
     java.util.Date       TIMESTAMP

TABLE B-5: Conversions performed by `setObject` and `setNull` between Java object types and target JDBC types

                          T S I B R F D D N B B C V L B V L D T T A B C S R D J R N N L N S
                          I M N I E L O E U I O H A O I A O A I I R L L T E A A O C V O C Q
                          N A T G A O U C M T O A R N N R N T M M R O O R F T V W H A N L L
                          Y L E I L A B I E   L R C G A B G E E E A B B U   A A I A R G O X
                          I L G N   T L M R   E   H V R I V E   S Y     C   L _ D R C N B M
                          N I E T     E A I   A   A A Y N A     T       T   I O     H V   L
                          T N R         L C   N   R R   A R     A           N B     A A
                            T                       C   R B     M           K J     R R
                                                    H   Y I     P                     C
     Java type
     ==================== = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
     String               x x x x x x x x x x x x x x x x x x x x . . . . . . . . x x x . .
     java.math.BigDecimal x x x x x x x x x x x x x . . . . . . . . . . . . . . . . . . . .
     Boolean              x x x x x x x x x x x x x . . . . . . . . . . . . . . . . . . . .
     Byte                 x x x x x x x x x x x x x . . . . . . . . . . . . . . . . . . . .
     Short                x x x x x x x x x x x x x . . . . . . . . . . . . . . . . . . . .
     Integer              x x x x x x x x x x x x x . . . . . . . . . . . . . . . . . . . .
     Long                 x x x x x x x x x x x x x . . . . . . . . . . . . . . . . . . . .
     Float                x x x x x x x x x x x x x . . . . . . . . . . . . . . . . . . . .
     Double               x x x x x x x x x x x x x . . . . . . . . . . . . . . . . . . . .
     byte[]               . . . . . . . . . . . . . . x x x . . . . . . . . . . . . . . . .
     java.math.BigInteger . . . x . . . . . . . x x x . . . . . . . . . . . . . . . . . . .
     java.sql.Date        . . . . . . . . . . . x x x . . . x . x . . . . . . . . . . . . .
     java.sql.Time        . . . . . . . . . . . x x x . . . . x x . . . . . . . . . . . . .
     java.sql.Timestamp   . . . . . . . . . . . x x x . . . x x x . . . . . . . . . . . . .
     java.sql.Array       . . . . . . . . . . . . . . . . . . . . x . . . . . . . . . . . .
     java.sql.Blob        . . . . . . . . . . . . . . . . . . . . . x . . . . . . . . . . .
     java.sql.Clob        . . . . . . . . . . . . . . . . . . . . . . x . . . . . . . . . .
     java.sql.Struct      . . . . . . . . . . . . . . . . . . . . . . . x . . . . . . . . .
     java.sql.Ref         . . . . . . . . . . . . . . . . . . . . . . . . x . . . . . . . .
     java.net.URL         . . . . . . . . . . . . . . . . . . . . . . . . . x . . . . . . .
     Java class           . . . . . . . . . . . . . . . . . . . . . . . . . . x . . . . . .
     java.sql.Rowid       . . . . . . . . . . . . . . . . . . . . . . . . . . . x . . . . .
     java.sql.NClob       . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . x .
     java.sql.SQLXML      . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . x
     java.util.Calendar   . . . . . . . . . . . x x x . . . x x x . . . . . . . . . . . . .
     java.util.Date       . . . . . . . . . . . x x x . . . x x x . . . . . . . . . . . . .

TABLE B-6: Use of `ResultSet` getter methods to retrieve JDBC data types

                          T S I B R F D D N B B C V L B V L D T T C B A R D S J R N N L N S
                          I M N I E L O E U I O H A O I A O A I I L L R E A T A O C V O C Q
                          N A T G A O U C M T O A R N N R N T M M O O R F T R V W H A N L L
                          Y L E I L A B I E   L R C G A B G E E E B B A   A U A I A R G O X
                          I L G N   T L M R   E   H V R I V E   S     Y   L C _ D R C N B M
                          N I E T     E A I   A   A A Y N A     T         I T O     H V   L
                          T N R         L C   N   R R   A R     A         N   B     A A
                            T                       C   R B     M         K   J     R R
                                                    H   Y I     P                     C
     Java type
     ==================== = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
     getByte              X x x x x x x x x x x x x . . . . . . . . . . . . . . x . . . . .
     getShort             x X x x x x x x x x x x x . . . . . . . . . . . . . . . . . . . .
     getInt               x x X x x x x x x x x x x . . . . . . . . . . . . . . . . . . . .
     getLong              x x x X x x x x x x x x x . . . . . . . . . . . . . . . . . . . .
     getFloat             x x x x X x x x x x x x x . . . . . . . . . . . . . . . . . . . .
     getDouble            x x x x x X X x x x x x x . . . . . . . . . . . . . . . . . . . .
     getBigDecimal        x x x x x x x X X x x x x . . . . . . . . . . . . . . . . . . . .
     getBoolean           x x x x x x x x x X x x x . . . . . . . . . . . . . . . . . . . .
     getString            x x x x x x x x x x x X X x x x x x x x . . . . x . . . x x x . .
     getNString           x x x x x x x x x x x x x x x x x x x x . . . . x . . . X X x . .
     getBytes             . . . . . . . . . . . . . . X X x . . . . . . . . . . . . . . . .
     getDate              . . . . . . . . . . . x x x . . . X . x . . . . . . . . . . . . .
     getTime              . . . . . . . . . . . x x x . . . . X x . . . . . . . . . . . . .
     getTimestamp         . . . . . . . . . . . x x x . . . x x X . . . . . . . . . . . x .
     getAsciiStream       . . . . . . . . . . . x x X x x x . . . x . . . . . . . . . . . x
     getBinaryStream      . . . . . . . . . . . . . . x x X . . . . x . . . . . . . . . x x
     getCharacterStream   . . . . . . . . . . . x x X x x x . . . x . . . . . . . x x x x x
     getNCharacterStream  . . . . . . . . . . . x x x x x x . . . x . . . . . . . x x X x x
     getClob              . . . . . . . . . . . . . . . . . . . . X . . . . . . . . . . x .
     getNClob             . . . . . . . . . . . . . . . . . . . . x . . . . . . . . . . X .
     getBlob              . . . . . . . . . . . . . . . . . . . . . X . . . . . . . . . . .
     getArray             . . . . . . . . . . . . . . . . . . . . . . X . . . . . . . . . .
     getRef               . . . . . . . . . . . . . . . . . . . . . . . X . . . . . . . . .
     getURL               . . . . . . . . . . . . . . . . . . . . . . . . X . . . . . . . .
     getObject            x x x x x x x x x x x x x x x x x x x x x x x x x X X x x x x x x
     getRowId             . . . . . . . . . . . . . . . . . . . . . . . . . . . X . . . . .
     getSQLXML            . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . X

### Nested Class Summary

Nested Classes
`static class` `SqlType.Method` Getter methods in `ResultSet`.

### Enum Constant Summary

Enum Constants
Enum Constant and Description
`ANY`
`ARRAY`
`BIGINT`
`BINARY`
`BIT`
`BLOB`
`BOOLEAN`
`CHAR`
`CLOB`
`COLUMN_LIST`
`CURSOR`
`DATALINK`
`DATE`
`DECIMAL`
`DISTINCT`
`DOUBLE`
`FLOAT`
`INTEGER`
`INTERVAL_DAY_TIME`
`INTERVAL_YEAR_MONTH`
`JAVA_OBJECT`
`LONGNVARCHAR`
`LONGVARBINARY`
`LONGVARCHAR`
`MAP`
`MULTISET`
`NCHAR`
`NCLOB`
`NULL`
`NUMERIC`
`NVARCHAR`
`OTHER`
`REAL`
`REF`
`ROW`
`ROWID`
`SMALLINT`
`SQLXML`
`STRUCT`
`SYMBOL`
`TIME`
`TIMESTAMP`
`TINYINT`
`VARBINARY`
`VARCHAR`

### Field Summary

Fields
`private static Map<Integer,SqlType>` `BY_ID`
`Class` `clazz` Default Java type for this SQL type, as described in table B-1.
`static Map<SqlType.Method,EnumSet<SqlType>>` `GET_LIST`
`int` `id` Type id as appears in `Types`, e.g.
`Class` `internal` Class used internally in Calcite to represent instances of this type.
`Class` `serial` Class used to serialize values of this type as JSON.
`static Map<Class,EnumSet<SqlType>>` `SET_LIST`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`Class` `boxedClass()` Returns the boxed type.
`static boolean` `canGet(SqlType.Method method, SqlType sqlType)` Returns whether `ResultSet.getInt(int)` and similar methods can convert a value to a particular SQL type.
`static boolean` `canSet(Class aClass, SqlType sqlType)` Returns whether `PreparedStatement.setObject(int, java.lang.Object, int)` and `PreparedStatement.setNull(int, int)` can assign a value of a particular class to a column of a particular SQL type.
`private static <E extends Enum<E>> EnumSet<E>` `concat(Collection<E>... ess)`
`static Iterable<Map.Entry<Class,SqlType>>` `getSetConversions()` Returns the entries in JDBC table B-5.
`static SqlType` `valueOf(int type)`
`static SqlType` `valueOf(String name)` Returns the enum constant of this type with the specified name.
`static SqlType[]` `values()` Returns an array containing the constants of this enum type, in the order they are declared.

### Methods inherited from class java.lang.Enum

`clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf`

### Methods inherited from class java.lang.Object

`getClass, notify, notifyAll, wait, wait, wait`

### Enum Constant Detail

#### BIT

    public static final SqlType BIT

#### BOOLEAN

    public static final SqlType BOOLEAN

#### TINYINT

    public static final SqlType TINYINT

#### SMALLINT

    public static final SqlType SMALLINT

#### INTEGER

    public static final SqlType INTEGER

#### BIGINT

    public static final SqlType BIGINT

#### NUMERIC

    public static final SqlType NUMERIC

#### DECIMAL

    public static final SqlType DECIMAL

#### FLOAT

    public static final SqlType FLOAT

#### REAL

    public static final SqlType REAL

#### DOUBLE

    public static final SqlType DOUBLE

#### DATE

    public static final SqlType DATE

#### TIME

    public static final SqlType TIME

#### TIMESTAMP

    public static final SqlType TIMESTAMP

#### INTERVAL_YEAR_MONTH

    public static final SqlType INTERVAL_YEAR_MONTH

#### INTERVAL_DAY_TIME

    public static final SqlType INTERVAL_DAY_TIME

#### CHAR

    public static final SqlType CHAR

#### VARCHAR

    public static final SqlType VARCHAR

#### LONGVARCHAR

    public static final SqlType LONGVARCHAR

#### BINARY

    public static final SqlType BINARY

#### VARBINARY

    public static final SqlType VARBINARY

#### LONGVARBINARY

    public static final SqlType LONGVARBINARY

#### NULL

    public static final SqlType NULL

#### ANY

    public static final SqlType ANY

#### SYMBOL

    public static final SqlType SYMBOL

#### MULTISET

    public static final SqlType MULTISET

#### ARRAY

    public static final SqlType ARRAY

#### BLOB

    public static final SqlType BLOB

#### CLOB

    public static final SqlType CLOB

#### SQLXML

    public static final SqlType SQLXML

#### MAP

    public static final SqlType MAP

#### DISTINCT

    public static final SqlType DISTINCT

#### STRUCT

    public static final SqlType STRUCT

#### REF

    public static final SqlType REF

#### DATALINK

    public static final SqlType DATALINK

#### JAVA_OBJECT

    public static final SqlType JAVA_OBJECT

#### ROWID

    public static final SqlType ROWID

#### NCHAR

    public static final SqlType NCHAR

#### NVARCHAR

    public static final SqlType NVARCHAR

#### LONGNVARCHAR

    public static final SqlType LONGNVARCHAR

#### NCLOB

    public static final SqlType NCLOB

#### ROW

    public static final SqlType ROW

#### OTHER

    public static final SqlType OTHER

#### CURSOR

    public static final SqlType CURSOR

#### COLUMN_LIST

    public static final SqlType COLUMN_LIST

### Field Detail

#### id

    public final int id

Type id as appears in `Types`, e.g. `Types.INTEGER`.

#### clazz

    public final Class clazz

Default Java type for this SQL type, as described in table B-1.

#### internal

    public final Class internal

Class used internally in Calcite to represent instances of this type.

#### serial

    public final Class serial

Class used to serialize values of this type as JSON.

#### BY_ID

    private static final Map<Integer,SqlType> BY_ID

#### SET_LIST

    public static final Map<Class,EnumSet<SqlType>> SET_LIST

#### GET_LIST

    public static final Map<SqlType.Method,EnumSet<SqlType>> GET_LIST

### Method Detail

#### values

    public static SqlType[] 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 (SqlType c : SqlType.values())
        System.out.println(c);

Returns:
  an array containing the constants of this enum type, in the order they are declared

#### valueOf

    public static SqlType valueOf(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:
  `IllegalArgumentException` - if this enum type has no constant with the specified name
  `NullPointerException` - if the argument is null

#### valueOf

    public static SqlType valueOf(int type)

#### boxedClass

    public Class boxedClass()

Returns the boxed type.

#### getSetConversions

    public static Iterable<Map.Entry<Class,SqlType>> getSetConversions()

Returns the entries in JDBC table B-5.

#### concat

    @SafeVarargs
    private static <E extends Enum<E>> EnumSet<E> concat(Collection<E>... ess)

#### canSet

    public static boolean canSet(Class aClass,
                                 SqlType sqlType)

Returns whether `PreparedStatement.setObject(int, java.lang.Object, int)` and `PreparedStatement.setNull(int, int)` can assign a value of a particular class to a column of a particular SQL type.

The JDBC standard describes the mapping in table B-5.

#### canGet

    public static boolean canGet(SqlType.Method method,
                                 SqlType sqlType)

Returns whether `ResultSet.getInt(int)` and similar methods can convert a value to a particular SQL type.

The JDBC standard describes the mapping in table B-6.