• 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 with unicode database web application

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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??
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You showed up just in time for the waffles! And this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic