Value '0000-00-00' can not be represented as java.sql.Date
来源:互联网 发布:萌一句话知乎 编辑:程序博客网 时间:2024/06/06 09:06
java.sql.SQLException: Value ‘0000-00-00 00:00:00’ can not be represented as java.sql.Timestamp
问题描述, 在java应用程序中,数据表中有记录的time字段(属性为timestamp)其值为:“0000-00-00 00:00:00”
程序使用select 语句从中取数据时出现以下异常:
java.sql.SQLException:Value ‘0000-00-00’ can not be represented as java.sql.Date
这是因为 “0000-00-00 00:00:00”在mysql中是作为一个特殊值存在的,但是在Java中, java.sql.Date 会被视为 不合法的值,被JVM认为格式不正确。
解决办法:
在jdbc的url加上 zeroDateTimeBehavior参数:
jdbc:mysql://192.168.1.202:3306/com?autoReconnect=true&useUnicode=true&characterset=utf8mb4&zeroDateTimeBehavior=convertToNull
0 0
- 问题解决:java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
- java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
- java.sql.SQLException: Value '0000-00-00' can not be represented as java.sql.Date 解决方法
- java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
- 问题解决:java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
- java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
- java.sql.SQLException:Value ‘0000-00-00′ can not be represented as java.sql.Date .
- 问题解决:java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
- java.sql.SQLException:Value ’0000-00-00′ can not be represented as java.sql.Date
- 问题解决:java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
- 问题解决:java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
- java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
- 问题解决:java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
- java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
- java.sql.SQLException:value;'0000-00-00'can not be represented as java.sql.date
- 解决java.sql.SQLException: Value '0000-00-00' can not be represented as java.sql.Date
- 问题解决:java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
- Value '0000-00-00' can not be represented as java.sql.Date错误修改
- Struts2学习(每天一点进步)
- MySQL触发器使用详解
- 在Eclipse中创建Maven的Web项目时出现错误:An internal error occurred during: "Retrieving archetypes:"
- Eclipse 扩展点常量ID
- java控制台如何把一个对象的信息打印出来?
- Value '0000-00-00' can not be represented as java.sql.Date
- apache kafka监控系列-KafkaOffsetMonitor
- VS2010调试之“编辑并继续”
- 读取properties文件,工具类。
- 计算n的阶乘
- [leetcode] 【数组】 136. Single Number
- Java中的基础----this的使用
- 【高性能】Linux远程VNC桌面
- selenium学习-WebDriver 与文件系统