I have a column of date type in MySQL database which is not null and value is set to default '0000-00-00'. When I try to fetch a row with a date values composed entirely of zeros in NetBeans's Database Explorer I get the following error:
Error code 0, SQL state S1009: Value '0000-00-00' can not be represented as java.sql.Date Line 1, column 1
This is an error from the JDBC driver which is used by NetBeans to connect MySQL server. The default behavior of the database driver is to raise an exception. To change this you need to pass an additional property to the JDBC connection URL:
jdbc:mysql://localhost:3306/test?zeroDateTimeBehavior=convertToNull
Other possible values of the property are the default exception and round.
More info can be found here: http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-configuration-properties.html
No comments:
Post a Comment