'0000-00-00 00:00:00'不能表示为java.sql.Timestamp错误 [英] '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp error

查看:1067
本文介绍了'0000-00-00 00:00:00'不能表示为java.sql.Timestamp错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含日期的数据库表

I have a database table containing dates

 (`date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'). 

我正在使用MySQL。有时,数据会在没有日期的情况下传递给数据库。因此,当使用日期列调用表数据时,日期值会自动分配给 0000-00-00 00:00:00
/ p>

I'm using MySQL. From the program sometimes data is passed without the date to the database. So, the date value is auto assigned to 0000-00-00 00:00:00 when the table data is called with the date column it gives error

...'0000-00-00 00:00:00' can not be represented as java.sql.Timestamp.......

我试图将空值传递给插入数据的日期,但它得到了分配到当前时间。

I tried to pass null value to the date when inserting data, but it gets assign to the current time.

有没有办法在不更改表格结构的情况下获得 ResultSet ? / p>

Is there any way I can get the ResultSet without changing the table structure?

推荐答案

您可以直接在数据源配置中使用此JDBC URL:

You can use this JDBC URL directly in your data source configuration:

jdbc:mysql:// yourserver:3306 / yourdatabase?zeroDateTimeBehavior = convertToNull

jdbc:mysql://yourserver:3306/yourdatabase?zeroDateTimeBehavior=convertToNull

这篇关于'0000-00-00 00:00:00'不能表示为java.sql.Timestamp错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆