Trail: JDBC(TM) Database Access
Lesson: JDBC Basics
Use of ResultSet.getXXX: Table-Free Versions
Because the large table in Retrieving Values from Result Sets can be hard to read (especially with screen readers), this page presents two alternate versions of the table's data. The first version displays the information you can get by looking down each column of the table. The second displays the information for each row of the table. If you have any suggestions for improving this page, please tell us.

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
Previous page: Retrieving Values from Result Sets