This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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?
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.
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.
Joined: Feb 14, 2006
Anyone know how to solve my 256 chars nightmare?
Joined: Feb 14, 2006
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?