Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem when inserts data

 
Luong Nguyen
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic