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 Problem when inserts data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Problem when inserts data" Watch "Problem when inserts data" New topic
Author

Problem when inserts data

Luong Nguyen
Ranch Hand

Joined: May 06, 2001
Posts: 31
Hi all,
This is my problem: I have a database. I use JDBC with MS SQL on Windows 2000 to access the database. In my database, I create a table and the table has a field which is VARCHAR(50). When I insert data into the table, even if the length of the data is less than 50 but the value of the field is always 50 characters.
Please help me! Thanks in advance.
Luong.
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

which jdbc driver are you using? Are there any known bugs? Are you sure it is a VARCHAR field in the DB and not a CHAR?? What is the length of the String before the insert to the DB?
very puzzling!
Jamie
Michael Fitzmaurice
Ranch Hand

Joined: Aug 22, 2001
Posts: 168
Hi
One thing you could try is trimming the String variable before sending it to the DB via JDBC (use the <code>trim()</code> of the String class).
May not make any difference, but just a thought...
The first thing, as always, is to figure our WHERE this behaviour is taking place (i.e. is it in the Java code, the JDBC call, the stored proc/SQL, or the database itself?)

------------------
"One good thing about music - when it hits, you feel no pain"
Bob Marley


"One good thing about music - when it hits, you feel no pain" <P>Bob Marley
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Problem when inserts data
 
Similar Threads
Index column is null
Data size bigger than the max size for this type;
float value gets roundedoff in portlet
JDBC
Getting Every Five Record