How a value in a MySQL YEAR column is handled is controlled by the connection property yearIsDateType:
If yearIsDateType is
true
(the default), YEAR is mapped to the Java data typejava.sql.Date
.If yearIsDateType is
false
, YEAR is mapped to the Java data typejava.sql.Short
.
Connector/J follows the same rules that govern how values are inserted by a mysql client; see explanations in The YEAR Type for details.
Connector/J handles the retrieval of zero values from a YEAR column differently than a mysql client. Treatments of zero values depend on whether they are strings or numbers, and on the value of yearIsDateType:
If a string value of
'0'
,'00'
, or'000'
is entered into a YEAR column, when retrieved by Connector/J:If yearIsDateType is true, the retrieved value is equivalent to January 1, 2000 00:00:00.000.
If yearIsDateType is false, the retrieved value is
2000
If a numeric value of
0
,00
,000
, or0000
is entered into a YEAR column, when retrieved by Connector/J,If yearIsDateType is true, the retrieved value is equivalent to January 1, 2000 00:00:00.000.
If yearIsDateType is false, the retrieved value is
0