This week's book giveaways are in the iOS and Features new in Java 8 forums.
We're giving away four copies each of Barcodes with iOS: Bringing together the digital and physical worlds and Core Java for the Impatient and have the authors on-line!
See this thread and this one for details.
The moose likes JDBC and Relational Databases and the fly likes Data truncation issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Barcodes with iOS this week in the iOS forum
or Core Java for the Impatient in the Java 8 forum!

JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Data truncation issue" Watch "Data truncation issue" New topic
Author

Data truncation issue

liliya woland
Ranch Hand

Joined: Apr 11, 2006
Posts: 134
For some reason when one of my textareas gets written to db, I get SQL Data
truncation error in the column populated by that textarea.
So I made a loop, like this:
String sz = (String)frmData.get("T11");
// @ 65 gives DATA TRUNCATION ERROR - WHY? ... so now set to 60
if (sz.length() > 60){
sz=sz.substring(0, 60);
frmData.put("T11",sz);
}
to cut down on user input, and as you see, when characters from the testarea go over 65, I get the error.
I tried setting that db column to LONGTEXT, MEDIUMTEXT, VARCHAR(200) when it really should be no more than 100 characters, - and I got same "SQL DATA truncation error" no matter what the length for the column is set to.
I have other textareas, identical to the one described above, that populate LONGTEXT columns - no problem.
Can anyone tell me what's happening?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Data truncation issue