• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with unicode database web application

 
sai suresh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to have a unicode enabled database for the web site I'm developing. The current installation is jdk1.4, postgres 7.3.2, jboss 3.2.3 on redhat linux9.0. The unicode seems to work well with normal jsp files with resource bundles. But when I try to input unicode characters into the database, the unicode data is not stored the way I expect. instead all unicode input is sored as a weird character resembling 'a'.
few of my concerns include
I input the unicode characters into form fields using my own javascript keypad(displays unicode characters when keys are pressed). So, if I understand clearly, its ok only for the browser frontend. So, immediately if I access the same unicode input from my servlet program and output the same in a console, its displaying junk. is it that my linux machine has some part to play in handling unicode?
I set the database encoding to unicode while creating the database. I'm also not sure whether the database is working the way I intended because, each unicode character is stored as a 3 character length weird data resembling an 'a' which supposedly be 1 character length.
my point is, even though there is problem inbetween while storing and retrieving the data from a database, it shouldn't matter because the brower is the one which takes the unicode input and it is the one which should display the retrieved data( which is not understood by my machine). I doubt, the unicode data is garbled when my machine handles the unicode data it gets from the browser.
did i miss anything? any suggestions or comments??
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if the database doesn't store it correctly it can't send it back correctly either.
Possibly your JDBC driver (or the way you use it) can't handle Unicode and instead tries to save it all as single character ASCII thus causing the garbled data you're seeing.
Check what SQL datatype is expected. It may be that setString() from PreparedStatement doesn't work for you and you need setObject() instead.
 
sai suresh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is there any source where I can know more about tewaking the JDBC to work with Unicode. also, how can i be sure its the jdbc thats the culprit. do you suggest any tests for this.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64715
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch "saisuresh "!
You'll find this forum a great place to seek help on JSP pages, and there aren't many rules you'll have to worry about, but one is that proper names are required. Please take a look at the JavaRanch Naming Policy and change your display name to match it.
In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.
Thanks!
bear
JSP Forum Bartender
P.S. Since this topic is primarily DB-oriented, I'm moving this topic to the JDBC forum.
 
Benjamin Weaver
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have heard about--but have not yet experienced first hand--a problem with PostgreSQL JDBC drivers and unicode. The workaround, I believe, was to call getBytes() instead of getString() when processing your resultSet. Do a search on getBytes() in the PostgreSQL search page. Maybe you will find this thread.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic