Date Value 0000-00-00 can not be used in java Date

1

First of all, yes, I already added ?zeroDateTimeBehavi‌​or=convertToNull in the connection URL, the problem is that in the query the date zeroed does not come null and always releases the following Exception:

java.sql.SQLException: Value '0000-00-00' can not be represented as java.sql.Date

I have already debugged and always for the same zeroed date being called by the ResultSet

regC100.setDtDoc(resultSet.getDate(14));
    
asked by anonymous 11.04.2017 / 14:22

2 answers

1

The other fields were omitted but I was able to get them all by calling them individually with ALIAS the way I could solve it was like this:

SELECT if(DT_DOC='0000-00-00',NULL,DT_DOC) as DT_DOC FROM reg_c100;
    
11.04.2017 / 20:11
0

In MySql 0000-00-00 is considered a valid date, but can not be represented as java.sql.Date .

You can use a query that returns NULL in case of date 0000-00-00 , or the actual value otherwise:

SELECT
  CASE WHEN 'data'!='0000-00-00' THEN 'data' END date
FROM
  suaTabela
    
11.04.2017 / 14:29