File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Data truncation issue" Watch "Data truncation issue" New topic

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);
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:
subject: Data truncation issue
It's not a secret anymore!