我喜欢@a_horse_with_no_name的答案,但是,如果您无法控制连接,则可以将查询更改为返回a
null:
select ... case when my_date_col = '0000-00-00' then null else my_date_col end as my_date_col, ...
或更简洁,但仅限mysql选项:
if(my_date_col = '0000-00-00', null, my_date_col) as my_date_col
另外,建议您谨慎更改整个应用程序的JDBC行为,因为您可能会破坏依赖于此类返回日期的代码-
也许它们会
rs.getString(i)代替使用。您必须对所有其他查询进行回归测试才能确定。



