Encoding problems with locale and jdbc - ResultSet.getString() [message #91173] |
Wed, 15 May 2002 08:04 |
lenon
Messages: 5 Registered: May 2002
|
Junior Member |
|
|
I get correct(slovak) encoding from ResultSet.getString() from my thin jdbc java application connecting to oracle8i, when 'regional options' locale on my w2k is set to slovak; switching to english i get '?'-question marks instead of correct characters.
I tried to alter session and change NLS_LANGUAGE and
NLS_TERRITORY to slovak; as well to set environment variable NLS_LANG, along with
Locale.setDefault(new Locale("sk","SK"))
No success, it works only with windows SK locale on.
What can I do?
I wonder what jdbc or jvm itself is getting from system environment and how it interfere with encoding, whether data are screwed in db-java transfer or java-screen (out.print())?
|
|
|
Re: Encoding problems with locale and jdbc - ResultSet.getString() [message #91174 is a reply to message #91173] |
Thu, 16 May 2002 00:03 |
Mohamed Itani
Messages: 2 Registered: March 2002
|
Junior Member |
|
|
Hello,
This is a serious problem, I already faced it with hungarian characters??
Can anybody suggests a solution for that??
Is there any solution on earth but changing the driver??
I already tried the nls_charset12.zip library but in vain.
This is so serious and it could prevent people from using the oracle jdbc/thin driver when they love it.
Best Regards
Itani Mohamed
|
|
|
Solution [message #91175 is a reply to message #91173] |
Thu, 16 May 2002 07:29 |
lenon
Messages: 5 Registered: May 2002
|
Junior Member |
|
|
I found solution to my problem, it has nothing to do with jdbc.
It's about character<->bytes encoding, as I suspected,
print/write methods of java writers classes use
'platform's default encoding' which is set by regional
settings of os; i tried just to add this line to my program: System.setProperty("file.encoding","CP1250");
(i need windows 1250 code page); but it doesn't work properly for me.
The solution is to set proper encoding to output writer
class. If you write to file, you need something like this:
FileOutputStream outt = new FileOutputStream("output.txt");
PrintWriter out = new PrintWriter(new OutputStreamWriter(outt,"WINDOWS-1250")); //or "ISO-8859-2" etc
out.println(resultset.getString(1)); //should work now
if you write to screen, you'll need wrap System.out stream
PrintWriter sout =new PrintWriter(new OutputStreamWriter(System.out,"WINDOWS-1250"),true);
sout.println(rs.getString(1)); //should work now
|
|
|