There is a column type DATETIME and default value as “0000-00-00 00:00:00″ in MySQL. When Using JSP with JDBC query and get result via getString, there arise an error:
java.sql.SQLException: Value ’0000-00-00 ‘ can not be represented as java.sql.Timestamp
As far as I see, this is a new feature of JDBC since version 3.1. However I did not encounter (or I ignore) it for a long time.
The value of MySQL is not valid in JAVA and the solution is to add a parameter in connection. Reference is here: Driver/Datasource Class Names, URL Syntax and Configuration Properties for Connector/J
That is, add zeroDateTimeBehavior=convertToNull into JDBC connection. and it works. 🙂