Connector/J (JDBC) Reference
2077
The conversions that are always guaranteed to work are listed in the following table. The first column
lists one or more MySQL data types, and the second column lists one or more Java types to which the
MySQL types can be converted.
Table 20.24. Connection Properties - Miscellaneous
These MySQL Data Types
Can always be converted to these Java types
CHAR, VARCHAR, BLOB, TEXT, ENUM, and
SET
java.lang.String,
java.io.InputStream, java.io.Reader,
java.sql.Blob, java.sql.Clob
FLOAT, REAL, DOUBLE PRECISION,
NUMERIC, DECIMAL, TINYINT, SMALLINT,
MEDIUMINT, INTEGER, BIGINT
java.lang.String, java.lang.Short,
java.lang.Integer,
java.lang.Long, java.lang.Double,
java.math.BigDecimal
DATE, TIME, DATETIME, TIMESTAMP
java.lang.String, java.sql.Date,
java.sql.Timestamp
Note
Round-off, overflow or loss of precision may occur if you choose a Java numeric
data type that has less precision or capacity than the MySQL data type you are
converting to/from.
The
ResultSet.getObject()
method uses the type conversions between MySQL and
Java types, following the JDBC specification where appropriate. The value returned by
ResultSetMetaData.GetColumnClassName()
is also shown below. For more information on the
java.sql.Types
classes see
Java 2 Platform Types
.
Table 20.25. MySQL Types to Java Types for ResultSet.getObject()
MySQL Type Name
Return value of
GetColumnClassName
Returned as Java Class
BIT(1)
(new in
MySQL-5.0)
BIT
java.lang.Boolean
BIT( > 1)
(new in
MySQL-5.0)
BIT
byte[]
TINYINT
TINYINT
java.lang.Boolean
if the configuration
property
tinyInt1isBit
is set to
true
(the default) and the storage size is 1, or
java.lang.Integer
if not.
BOOL
,
BOOLEAN
TINYINT
See
TINYINT
, above as these are aliases for
TINYINT(1)
, currently.
SMALLINT[(M)]
[UNSIGNED]
SMALLINT
[UNSIGNED]
java.lang.Integer
(regardless if
UNSIGNED
or not)
MEDIUMINT[(M)]
[UNSIGNED]
MEDIUMINT
[UNSIGNED]
java.lang.Integer,
if
UNSIGNED
java.lang.Long
(C/J 3.1 and earlier), or
java.lang.Integer
for C/J 5.0 and later
INT,INTEGER[(M)]
[UNSIGNED]
INTEGER [UNSIGNED] java.lang.Integer
, if
UNSIGNED
java.lang.Long
BIGINT[(M)]
[UNSIGNED]
BIGINT [UNSIGNED]
java.lang.Long
, if UNSIGNED
java.math.BigInteger
FLOAT[(M,D)]
FLOAT
java.lang.Float
DOUBLE[(M,B)]
DOUBLE
java.lang.Double
DECIMAL[(M[,D])]
DECIMAL
java.math.BigDecimal
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...