博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
mysql驱动使用的zeroDateTimeBehavior=convertToNull与or...
阅读量:6734 次
发布时间:2019-06-25

本文共 1374 字,大约阅读时间需要 4 分钟。

hot3.png

在使用mysql-connector-java-3.1.12-bin.jar时,发现程序里写了:
String url=something;
DBUtil.getConnection(url + "&zeroDateTimeBehavior=convertToNull","org.gjt.mm.mysql.Driver");
下面是对这两个参数解惑,留着自己以后查找看看
1.org.gjt.mm.mysql.Driver
The MySQL JDBC driver was initially developed by a hobbyist. It's later donated to MySQL where they renamed the package/classname. The old classname is kept for backwards compatibility reasons, but if you can, you should update it to com.mysql.jdbc.Driver as soon as possible.
2.zeroDateTimeBehavior=convertToNull
Getting JDBC Connection from Java,Useful Parameters:zeroDateTimeBehavior
This is used for handling PHP style 0000-00-00 dates in databases.
PHP applications often use '0000-00-00' instead of NULL for dates. This works great for PHP, however Java, and thus Hibernate throw a JDBCException as that '0000-00-00' can not be represented as java.sql.Date.
Exceptions in the wm.log are of the form:
Cannot convert value '0000-00-00 00:00:00' from column 4 to TIMESTAMP.; nested exception is java.sql.SQLException: Cannot convert value '0000-00-00 00:00:00' from column 4 to TIMESTAMP.
This can be handled by adding the JDBC Parameter: zeroDateTimeBehavior=convertToNull to your JDBC connection.
To add this to the db connection, open the db connection settings. Append 
?zeroDateTimeBehavior=convertToNull

转载于:https://my.oschina.net/forrest420/blog/110049

你可能感兴趣的文章
bash算数运算&命令引用
查看>>
磁盘分区
查看>>
.net core 上传excel文件
查看>>
公有云时代的售前打单
查看>>
磁盘阵列 RAID
查看>>
10.16/10.17/10.18 iptables nat表应用
查看>>
布尔类型传递参数
查看>>
Spring Boot 2.x基础教程:快速入门
查看>>
采购管理和信息(文档)和配置管理作业
查看>>
ios之coredata(二)
查看>>
SSD固态硬盘优化(转)
查看>>
Asymptote 学习记录(5) 模块roundedpath的用法
查看>>
【第41题】【062题库】2019年OCP认证062考试新题
查看>>
1.06 在WHERE子句中引用取别名的列
查看>>
JBPM流程部署之流程版本升级
查看>>
Java面向对象概述
查看>>
(转)Spring读书笔记-----Spring的Bean之Bean的基本概念
查看>>
NUC1016 斐波那契数列
查看>>
hadoop安装
查看>>
【编码的法则】谨慎的使用static
查看>>