mysql驱动使用的zeroDateTimeBehavior=convertToNull与or...

在使用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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值