How to read each JDBC type

Version 1: How to read each JDBC type

This section lists the ResultSet.getXXX methods recommended and allowed for retrieving data of each JDBC type.
TINYINT: getByte (recommended)
Can also be read using getShort, getInt, getLong, getFloat, getDouble, getBigDecimal, getBoolean, getString, getObject

 

SMALLINT: getShort (recommended)
Can also be read using getByte, getInt, getLong, getFloat, getDouble, getBigDecimal, getBoolean, getString, getObject

 

INTEGER: getInt (recommended)
Can also be read using getByte, getShort, getLong, getFloat, getDouble, getBigDecimal, getBoolean, getString, getObject

 

BIGINT: getLong (recommended)
Can also be read using getByte, getShort, getInt, getFloat, getDouble, getBigDecimal, getBoolean, getString, getObject

 

REAL: getFloat (recommended)
Can also be read using getByte, getShort, getInt, getLong, getDouble, getBigDecimal, getBoolean, getString, getObject

 

FLOAT: getDouble (recommended)
Can also be read using getByte, getShort, getInt, getLong, getFloat, getBigDecimal, getBoolean, getString, getObject

 

DOUBLE: getDouble (recommended)
Can also be read using getByte, getShort, getInt, getLong, getFloat, getBigDecimal, getBoolean, getString, getObject

 

DECIMAL: getBigDecimal (recommended)
Can also be read using getByte, getShort, getInt, getLong, getFloat, getDouble, getBoolean, getString, getObject

 

NUMERIC: getBigDecimal (recommended)
Can also be read using getByte, getShort, getInt, getLong, getFloat, getDouble, getBoolean, getString, getObject

 

BIT: getBoolean (recommended)
Can also be read using getByte, getShort, getInt, getLong, getFloat, getDouble, getBigDecimal, getString, getObject

 

CHAR: getString (recommended)
Can also be read using getByte, getShort, getInt, getLong, getFloat, getDouble, getBigDecimal, getBoolean, getDate, getTime, getTimestamp, getAsciiStream, getUnicodeStream, getObject

 

VARCHAR: getString (recommended)
Can also be read using getByte, getShort, getInt, getLong, getFloat, getDouble, getBigDecimal, getBoolean, getDate, getTime, getTimestamp, getAsciiStream, getUnicodeStream, getObject

 

LONGVARCHAR: getAsciiStream, getUnicodeStream (both recommended)
Can also be read using getByte, getShort, getInt, getLong, getFloat, getDouble, getBigDecimal, getBoolean, getString, getDate, getTime, getTimestamp, getObject

 

BINARY: getBytes (recommended)
Can also be read using getString, getAsciiStream, getUnicodeStream, getBinaryStream, getObject

 

VARBINARY: getBytes (recommended)
Can also be read using getString, getAsciiStream, getUnicodeStream, getBinaryStream, getObject

 

LONGVARBINARY: getBinaryStream (recommended)
Can also be read using getString, getBytes, getAsciiStream, getUnicodeStream, getObject

 

DATE: getDate (recommended)
Can also be read using getString, getTimestamp, getObject

 

TIME: getTime (recommended)
Can also be read using getString, getTimestamp, getObject

 

TIMESTAMP: getTimestamp (recommended)
Can also be read using getString, getDate, getTime, getObject

 

Version 2: Which types each ResultSet.getXXX method can read

This section lists the JDBC types that each ResultSet.getXXX method supports.
getByte: TINYINT (recommended)
Can also read SMALLINT, INTEGER, BIGINT, REAL, FLOAT, DOUBLE, DECIMAL, NUMERIC, BIT, CHAR, VARCHAR, LONGVARCHAR

 

getShort: SMALLINT (recommended)
Can also read TINYINT, INTEGER, BIGINT, REAL, FLOAT, DOUBLE, DECIMAL, NUMERIC, BIT, CHAR, VARCHAR, LONGVARCHAR

 

getInt: INTEGER (recommended)
Can also read TINYINT, SMALLINT, BIGINT, REAL, FLOAT, DOUBLE, DECIMAL, NUMERIC, BIT, CHAR, VARCHAR, LONGVARCHAR

 

getLong: BIGINT (recommended)
Can also read TINYINT, SMALLINT, INTEGER, REAL, FLOAT, DOUBLE, DECIMAL, NUMERIC, BIT, CHAR, VARCHAR, LONGVARCHAR

 

getFloat: REAL (recommended)
Can also read TINYINT, SMALLINT, INTEGER, BIGINT, FLOAT, DOUBLE, DECIMAL, NUMERIC, BIT, CHAR, VARCHAR, LONGVARCHAR

 

getDouble: FLOAT, DOUBLE (both recommended)
Can also read TINYINT, SMALLINT, INTEGER, BIGINT, REAL, DECIMAL, NUMERIC, BIT, CHAR, VARCHAR, LONGVARCHAR

 

getBigDecimal: DECIMAL, NUMERIC (both recommended)
Can also read TINYINT, SMALLINT, INTEGER, BIGINT, REAL, FLOAT, DOUBLE, BIT, CHAR, VARCHAR, LONGVARCHAR

 

getBoolean: BIT (recommended)
Can also read TINYINT, SMALLINT, INTEGER, BIGINT, REAL, FLOAT, DOUBLE, DECIMAL, NUMERIC, CHAR, VARCHAR, LONGVARCHAR

 

getString: CHAR, VARCHAR (both recommended)
Can also read TINYINT, SMALLINT, INTEGER, BIGINT, REAL, FLOAT, DOUBLE, DECIMAL, NUMERIC, BIT, LONGVARCHAR, BINARY, VARBINARY, LONGVARBINARY, DATE, TIME, TIMESTAMP

 

getBytes: BINARY, VARBINARY (both recommended)
Can also read LONGVARBINARY

 

getDate: DATE (recommended)
Can also read CHAR, VARCHAR, LONGVARCHAR, TIMESTAMP

 

getTime: TIME (recommended)
Can also read CHAR, VARCHAR, LONGVARCHAR, TIMESTAMP

 

getTimestamp: TIMESTAMP (recommended)
Can also read CHAR, VARCHAR, LONGVARCHAR, DATE, TIME

 

getAsciiStream: LONGVARCHAR (recommended)
Can also read CHAR, VARCHAR, BINARY, VARBINARY, LONGVARBINARY

 

getUnicodeStream: LONGVARCHAR (recommended)
Can also read CHAR, VARCHAR, BINARY, VARBINARY, LONGVARBINARY

 

getBinaryStream: LONGVARBINARY (recommended)
Can also read BINARY, VARBINARY

 

getObject: (no recommended type)
Can read TINYINT, SMALLINT, INTEGER, BIGINT, REAL, FLOAT, DOUBLE, DECIMAL, NUMERIC, BIT, CHAR, VARCHAR, LONGVARCHAR, BINARY, VARBINARY, LONGVARBINARY, DATE, TIME, TIMESTAMP
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值