Bug #7461 | com.mysql.jdbc.MysqlDataTruncation error using load data infile | ||
---|---|---|---|
Submitted: | 21 Dec 2004 19:27 | Modified: | 31 Mar 2014 8:04 |
Reporter: | David Marshall | Email Updates: | |
Status: | Can't repeat | Impact on me: | |
Category: | Connector / J | Severity: | S2 (Serious) |
Version: | 3.1.5-gamma | OS: | Linux (Fedora Core 3) |
Assigned to: | Alexander Soklakov | CPU Architecture: | Any |
[21 Dec 2004 19:27]
David Marshall
[21 Dec 2004 20:15]
Mark Matthews
Does your code call Statement.getWarnings()? I'm trying to track down the NPE. The DataTruncation exception is as-expected, it's a new feature, and is required for JDBC compliance. You can turn off the DataTruncation functionality by using the connection property "jdbcCompliantTruncation" to 'false' (it's set to 'true' by default).
[22 Dec 2004 15:19]
David Marshall
Yes, I'm calling statement.getWarning() - no warnings logged in the default configuration (jdbcCompliantTruncation=true). N.B. I don't understand why JDBC truncation rules apply as I'm not using "LOAD DATA LOCAL INFILE", just a "LOAD DATA INFILE" statement. When I rerun with jdbcCompliantTruncation=false I get warnings returned, and no exception. Eventually I do get the NullPointerException, this time calling getWarning() - see attached log extract and stack trace: 2004-12-22 09:53:23 INFO test: loading CSV tables... 2004-12-22 09:53:23 WARN test: --- Warning --- 2004-12-22 09:53:23 WARN test: SQLState: 01000 2004-12-22 09:53:23 WARN test: Message : Data truncated for column 'OFFSET_FOR_FIRST_CHECKIN_DATE' at row 16 2004-12-22 09:53:23 WARN test: Vendor : 1265 2004-12-22 09:53:24 WARN test: --- Warning --- 2004-12-22 09:53:24 WARN test: SQLState: 01000 2004-12-22 09:53:24 WARN test: Message : Data truncated for column 'LOS' at row 2025 2004-12-22 09:53:24 WARN test: Vendor : 1265 2004-12-22 09:54:37 WARN test: --- Warning --- 2004-12-22 09:54:37 WARN test: SQLState: 01000 2004-12-22 09:54:37 WARN test: Message : Data truncated for column 'FIRST_CHECKIN_DATE_CHAR' at row 138 2004-12-22 09:54:37 WARN test: Vendor : 1265 2004-12-22 09:54:39 WARN test: --- Warning --- 2004-12-22 09:54:39 WARN test: SQLState: 01000 2004-12-22 09:54:39 WARN test: Message : Data truncated for column 'PROPERTY_ID' at row 7257 2004-12-22 09:54:39 WARN test: Vendor : 1265 2004-12-22 09:54:53 WARN test: --- Warning --- 2004-12-22 09:54:53 WARN test: SQLState: 01000 2004-12-22 09:54:53 WARN test: Message : Data truncated for column 'PROPERTY_ID' at row 50476 2004-12-22 09:54:53 WARN test: Vendor : 1265 2004-12-22 09:54:53 FATAL test: Fatal error: java.lang.NullPointerException at com.mysql.jdbc.Statement.getWarnings(Statement.java:690) at Test.showWarnings(Test.java:335) at Test.closeConnection(Test.java:278) at Test.run(Test.java:258) at Test.main(Test.java:922) There is a an extract of the first 50 lines or so in the first file (first truncation occurs on row 16, data looks fine to me). Thanks.
[22 Dec 2004 15:53]
Mark Matthews
> N.B. I don't understand why JDBC truncation rules apply as I'm not using "LOAD > DATA LOCAL INFILE", just a "LOAD DATA INFILE" statement. Truncation warnings can come from _any_ statement, the 'local' part of infile wouldn't affect that.
[14 Feb 2005 22:54]
Bugs System
No feedback was provided for this bug for over a month, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open".
[16 Jul 2009 15:37]
Hering Cheng
I was also getting com.mysql.jdbc.MysqlDataTruncation with version 3.1.8 of JDBC driver. After upgrading to the current 5.1.8 version, the error is now more explicit: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value: '2009-06-01 04:00:00 +0000' for column 'start' at row 1 at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3534) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3468) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:917) at com.mysql.jdbc.MysqlIO.sendFileToServer(MysqlIO.java:3433) at com.mysql.jdbc.MysqlIO.readResultsForQueryOrUpdate(MysqlIO.java:2552) at com.mysql.jdbc.MysqlIO.readAllResults(MysqlIO.java:1755) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2165) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2642) at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1634) at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1553) at org.apache.commons.dbcp.DelegatingStatement.executeUpdate(DelegatingStatement.java:228) So basically the JDBC driver does not like the value '2009-06-01 04:00:00 +0000' for a DATETIME column. However, the same LOAD FILE command and date file works from within EMS MySQL Manager Lite for Windows 3.4.0.4.
[31 Mar 2014 8:04]
Alexander Soklakov
I close this report as "Can't repeat" because there is no feedback for a long time and codebase is too old. Please, feel free to reopen it if the problem still exists in current driver.