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