• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem when inserts data

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic