Search code examples
javamysqlwindows-server-2012

MySQL changed to Windows 2012 and application throws error in datetime field


Our company switched from old AIX box environment to Windows Environment this weekend. The MySQL database was moved from AIX to Windows 2012 servers.

The application are throwing up errors on date fields for any insert statement. MySQL version on Windows is 5.1.56.

Is there any database level datetime setting that has to be changed in Windows environment? Any drivers to be installed? The application is on Java and may need lot of time changing the code.


Solution

  • Depending on the previous MySQL version (on AIX), below is a link to configuring MySQL "SQL-mode" to "emulate" some specific behaviors in MySQL. (The documentation link is for MySQL 5.5, but the date-related options could be the same for MySQL 5.1.) Might even suggesting looking at the configuration file on the previous version of MySQL to see if a "SQL-mode" might had been configured. SQL-mode can also set MYSQL to emulate previous versions of MySQL.

    Ref: http://dev.mysql.com/doc/refman/5.5/en/sql-mode.html

    Reading from the comments, using a NULL (or empty) string in the place of a date/timestamp field should be corrected in the Java code, but perhaps configuring the "SQL-mode" could mitigate your problem in the short run.