File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Batch inserts exception getting thrown.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Batch inserts exception getting thrown.." Watch "Batch inserts exception getting thrown.." New topic
Author

Batch inserts exception getting thrown..

Tad Dicks
Ranch Hand

Joined: Nov 16, 2004
Posts: 264
I keep getting the following error when trying to load data into a table from a file.

ERROR - com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data truncated for column 'contentId' at row 64
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data truncated for column 'contentId' at row 64


contentId in the tab delimted text file is always null (in the table it is an auto incremented field and this exception is thrown regardless on every file I try to load (although I haven't tried to load a file with less than 64 rows yet). I can't see anything different about row 64 than any other row (and it doesn't regardless of the data set on row 64). And the table seems to load just fine, but then it kicks out an exception screwing up the next steps. I suppose I could catch it and do nothing, though I loathe to do this with out knowing why.


-Tad
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3710
    
    5

Going out on a limb, but what was is the data type and size of content id in the database? You could be auto-incrementing past its size if it is small too small.

The error seems like its a data field problem but post mentions that the field is null and irregardless of the data the error comes up. I'd suggest posting your table defintion as well as a few example rows and see if that sheds any light.


My Blog: Down Home Country Coding with Scott Selikoff
Tad Dicks
Ranch Hand

Joined: Nov 16, 2004
Posts: 264
The field is a Bigint (mysql data type). And the input for the field is null b/c its an autoincrementing field. The fields in the input file are tab delimited and I've tried putting '' in and nothing for the id field. The strange thing is it seems to work fine. I guess whats the harm in truncating null data? but its still annoying.

-Tad
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Batch inserts exception getting thrown..