• Post Reply Bookmark Topic Watch Topic
  • New Topic

DB call-saves strange value on special charachters.  RSS feed

 
age spets
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Had a strange problem, that I solved, but would be nice to understand why the first DB-call didn't work:-)

ERROR!!!
UPDATE TMPOBJ.FANNTEST SET OMR�DE = '', ADRESSE = 'Stavangerg�ta 46' WHERE SAKNR='40154'

The adress turned up as(in my DB(DB2))-> Stavangerg$ta 46

NO ERROR!!!
UPDATE TMPOBJ.FANNTEST SET OMR�DE = 'SENT-N', ADRESSE = 'Stavangerg�ta 46' WHERE SAKNR='40154'

The adress turned up as(in my DB(DB2))-> Stavangerg�ta 46

info:Can also say I did a DB call whitout using java on my first call and then it worked, so this seems to be a java/db-2 problem for mee.

info:All other letters than the special norwegian letters was saved ok, with first db-call.

Any of you smart guys that have any ideas why the first DB call with empty value didnt work with special charachters?
 
age spets
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Extra information:

null values is ok.... but whenever I update a field with a value I have defined as ""(when the input String for the field is defiened as null it works, but not for ""), then I get this strange error on the fields that I update with special charachters.
 
Mattias Arthursson
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like there might be a bug in the JDBC driver you're using.
 
age spets
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That was so correct, thank you:-) Tried a DB2 driver instead of my JDBC driver and then it worked. Maybe I need to change some default settings on the JDBC-driver to make it work...
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have to say that my knee-jerk reaction when I saw your SQL was: ouch, I would never do this through anything other than a PreparedStatement and SQL parameters. I would distrust the ability of the JDBC driver to get the character set thing always right, quite apart from the deep problems that a Statement has with security (SQL injection attacks) and brittleness (use a single quote and you're dead).

- Peter
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!