File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes MSSQL and Unicode in WIndows and Linux Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "MSSQL and Unicode in WIndows and Linux" Watch "MSSQL and Unicode in WIndows and Linux" New topic

MSSQL and Unicode in WIndows and Linux

Ahsan Habib

Joined: Sep 17, 2008
Posts: 22
Java application reads mssql table data (unicode data) and forward to servlet. This scenario works fine when I run application in Ubuntu. But performance changes for these following scenarios:

secnario1: i move java application to windows which forwards database data to servlet running in ubuntu. Output in java app shows question marks (unicode issue) but servlet shows them correctly.

Scenario2: move both java app and servlet to windows, now both modules displaying question marks.

What I think - it should not be problem with database data since jdbc driver in linux works fine. But when I read data from windows (using same driver, later different versions of jdbc driver), though it shows ?? but servlet in linux could manage to get unicode data. What could be the problem and what should I do?

Thank you in advance.

Ahsan Habib
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
Where does it show question marks? Some kind of console? A web page? A console most likely can't display those characters. A web page needs to specify the proper encoding.

Make sure that you're specifying UTF-8 as the encoding wherever the data gets sent from one system to another.
Ahsan Habib

Joined: Sep 17, 2008
Posts: 22
For java app, I log output into file, and I run servlet in tomcat from eclipse - so, can see output in eclipse console.

I guess i figured out the problem. It was not jdbc driver problem. I changed Standards and Formats in Regional and Language settings (windows control panel) to Thai (before it was english) and now java app logs unicode data (read from mssql table) properly in log file. But eclipse console still show question marks. Later, I switched to jetty, and eclipse console prints Thai character properly. It was tomcat limitation. Adding UTF-8 for url handling in server.xml in tomcat solved the problem.

Worth to note that I was using apache HttpClient to forward data to servlet.
I agree. Here's the link:
subject: MSSQL and Unicode in WIndows and Linux
It's not a secret anymore!