简体   繁体   中英

Upgrading from MySQL 4.7 to 5.5, problematic date fields

I get this error in a legacy application running SQL from JSP pages (not my app):

java.sql.SQLException: Value '7?Some text from a field123133 2001-09-201?2001-10-01 08:37:191?0000-00-00 00:00:00' can not be represented as java.sql.Timestamp

It looks like the fields are concatenated and that is what the timestamp (and date, and datetime) is trying to decipher. Everything works fine if I run the query in mysql client and if I remove all date, datetime and timestamp fields. This happens when executeQuery(query) is run.

What I've done:

  • mysqldump the old database
  • imported to the new
  • changed the old mysql driver to mysql-connector-java-5.1.26-bin.jar
  • removed any old jdbc libraries
  • tomcat is running on java 1.7

I'm guessing it's a problem with libraries.

  • apache-tomcat-7.0.42
  • 5.5.32-0ubuntu0.12.04.1 (Ubuntu)
  • jdk1.7.0_15

Here's the tomcat/lib:

activation.jar catalina-tribes.jar el-api.jar jmxtools.jar naming-factory.jar poolman.xml tomcat-i18n-es.jar annotations-api.jar commons-codec-1.4.jar hssf-serializer.jar jsp-api.jar NetComponents.jar servlet-api.jar tomcat-i18n-fr.jar catalina-ant.jar cos.jar jasper-el.jar log4j.jar pg73jdbc3.jar tomcat-api.jar tomcat-i18n-ja.jar catalina-ha.jar dnsjava.jar jasper.jar mail.jar poi-hssf.jar tomcat-coyote.jar tomcat-jdbc.jar catalina.jar ecj-4.2.2.jar jmxri.jar mysql-connector-java-5.1.26-bin.jar poolman.jar tomcat-dbcp.jar tomcat-util.jar

And a few in the WEB-INF/lib:

fop.jar jce1_2_1.jar jsse.jar NetaxeptClientVirtual.jar soap.jar w3c.jar xerces.jar

Thanks for any help!

Adding

?zeroDateTimeBehavior=convertToNull

to the connection URL solved the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM