In mysql database, I have a field called "date" of date type.
When I am trying to retrieve the value in "date" field using getString() of java
I am getting an exception as thus:
java.sql.SQLException: Value '0000-00-00' can not be represented as java.sql.Date
is it that we can’t use getString() to fetch a date type value? or is the name “date” conflicting with the date field type? or is something else wrong?
Desc author
Field Type Null Default
date date YES NULL
I am just curious about this, thats all. As a solution, I tried converting the "date" using DATE_FORMAT(date, '%d %m %Y') as dt and it worked.
In java, when you try to get date from a
ResultSet, you need to usegetDateinstead ofgetString.SOURCE LINK
getStringwas able to work on thisDATE_FORMAT(date, '%d %m %Y')because its now in the string format.