• 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

Only 256 chars stored in DB field

 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I'm committing a String to a SqlServer database field. Problem is that the field is only storing the first 256 chars of the String. I initially set the field to a VARCHAR of 500, but still only 256 chars committed. I then set the db field value to be TEXT - still only accepting 256 chars.

I'm spitting the string out into the logs shortly before executing the PreparedStatement, and it prints into the log fine. Any ideas, folks?

Many thanks
As
 
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What database are you using and what is your character encoding? At the very least you should get a truncation error or a general error of some kind. Sometimes if the encoding is set wrong, it may store each character as 2-3 bytes but this usually is a limit that happens closer to 2k and 256 should be just fine. Also, attach your code so we can take a look.
 
Alana Sparx
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Scott

Character Encoding? No idea, how do I find this out? I'm making the assumption this is some default value?

The database is SqlServer 2000.

The code is:

the payload parameter is an XML String representing an object fed through an XML utility class that ultimately uses Castor. If I print this String out prior to preparing the sql statement, it looks fine, all the tags and data are contained inside it. But, when it's fed into the database, only the first 256 chars are there - there is no truncation error in the log!

I expect that this is some SqlServer2000 issue, so appreciate that this forum may not be the correct place for it, but, dammit, I'm desperate!

Thanks for any light you can shed on this.

As
 
Alana Sparx
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Annoyingly resurrected!

Anyone know how to solve my 256 chars nightmare?
 
Alana Sparx
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What a LOSER!!!

Next time I'll check the Sql Query Analyser, and make sure the display option is not set to 256 chars when executing statements.

Is there anything MS does that isn't utterly shit by default?
 
Bring me the box labeled "thinking cap" ... and then read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic