public enum SqlType extends Enum<SqlType>
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
Modifier and Type | Class and Description |
---|---|
static class |
SqlType.Method
Getter methods in
ResultSet . |
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 |
TIME_WITH_TIMEZONE |
TIMESTAMP |
TIMESTAMP_WITH_TIMEZONE |
TINYINT |
VARBINARY |
VARCHAR |
Modifier and Type | Field and Description |
---|---|
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 |
Modifier and Type | Method and Description |
---|---|
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. |
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.
|
public static final SqlType BIT
public static final SqlType BOOLEAN
public static final SqlType TINYINT
public static final SqlType SMALLINT
public static final SqlType INTEGER
public static final SqlType BIGINT
public static final SqlType NUMERIC
public static final SqlType DECIMAL
public static final SqlType FLOAT
public static final SqlType REAL
public static final SqlType DOUBLE
public static final SqlType DATE
public static final SqlType TIME
public static final SqlType TIMESTAMP
public static final SqlType INTERVAL_YEAR_MONTH
public static final SqlType INTERVAL_DAY_TIME
public static final SqlType CHAR
public static final SqlType VARCHAR
public static final SqlType LONGVARCHAR
public static final SqlType BINARY
public static final SqlType VARBINARY
public static final SqlType LONGVARBINARY
public static final SqlType NULL
public static final SqlType ANY
public static final SqlType SYMBOL
public static final SqlType MULTISET
public static final SqlType ARRAY
public static final SqlType BLOB
public static final SqlType CLOB
public static final SqlType SQLXML
public static final SqlType MAP
public static final SqlType DISTINCT
public static final SqlType STRUCT
public static final SqlType REF
public static final SqlType DATALINK
public static final SqlType JAVA_OBJECT
public static final SqlType ROWID
public static final SqlType NCHAR
public static final SqlType NVARCHAR
public static final SqlType LONGNVARCHAR
public static final SqlType NCLOB
public static final SqlType ROW
public static final SqlType OTHER
public static final SqlType CURSOR
public static final SqlType TIME_WITH_TIMEZONE
public static final SqlType TIMESTAMP_WITH_TIMEZONE
public static final SqlType COLUMN_LIST
public final int id
Types
,
e.g. Types.INTEGER
.public final Class clazz
public final Class internal
public final Class serial
public static final Map<SqlType.Method,EnumSet<SqlType>> GET_LIST
public static SqlType[] values()
for (SqlType c : SqlType.values()) System.out.println(c);
public static SqlType valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic static SqlType valueOf(int type)
public Class boxedClass()
public static Iterable<Map.Entry<Class,SqlType>> getSetConversions()
public static boolean canSet(Class aClass, SqlType sqlType)
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.
public static boolean canGet(SqlType.Method method, SqlType sqlType)
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.
Copyright © 2012-2024 Apache Software Foundation. All Rights Reserved.