Link to home
Start Free TrialLog in
Avatar of scarvallo
scarvallo

asked on

Default character set with java (Solaris 9)

I have an aplication wich was developed with a code generator for java and works in three layers. I installed the aplication server on a windows machine and pointed it to a Oracle Database running on a Solaris server and everything went fine.

After that first test I moved the aplication server to the solaris machine and pointing to the same Oracle Database and at first glance everything looks fine, but there is one problem. When I insert values with international characters (spanish) like accents or special letters from the client, the values that are actually stored in the database are different to the ones that I typed.

Anyway the problem only happens when the java aplication server is on the solaris, so I would like to know if there is a way to tell java to use an specific character set or change the default character set that is loaded. Is it posssible?? is it the problem???

Thanks.
Avatar of p_saravanan
p_saravanan

Default Loacle with charset is selected when you are logging into Solaris Server provided language packs are installed.
 
Set proper locale in the console from which you are starting Application Server.
Use LC_ALL=yourLocale
Check the directory /usr/lib/locale for available locales.

Also make sure all the three layers use the same charset. Else you have to convert the string to proper encoding in the application server.

Avatar of scarvallo

ASKER

I don't know how to set the locale variables for the sun environment, I use the command locale and I get the following output:

LANG=
LC_CTYPE="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_COLLATE="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_ALL=

I asume that this is wrong because as far as I understand that is the default for the 7 bit ASCII charset that doesn't have the special characters that I need. Since I need to work in spanish i asume that a locale that I can use is es_ES.ISO8859-1, so i checked the /etc/default/init and it has the following contents that look fine:

#ident  "@(#)init.dfl   1.6     00/05/27 SMI"
#
# This file is /etc/default/init.  /etc/TIMEZONE is a symlink to this file.
# This file looks like a shell script, but it is not.  To maintain
# compatibility with old versions of /etc/TIMEZONE, some shell constructs
# (i.e., export commands) are allowed in this file, but are ignored.

#
# Lines of this file should be of the form VAR=value, where VAR is one of
# TZ, LANG, CMASK, or any of the LC_* environment variables.
#
TZ=Europe/Madrid
CMASK=022
LC_COLLATE=es_ES.ISO8859-1
LC_CTYPE=es_ES.ISO8859-1
LC_MESSAGES=es
LC_MONETARY=es_ES.ISO8859-1
LC_NUMERIC=es_ES.ISO8859-1
LC_TIME=es_ES.ISO8859-1

Where can i set this values so I get the right output when I use locale.

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of p_saravanan
p_saravanan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ok, here is what i did, I created a small script with this lines in it:

unset LC_ALL
LC_ALL=es_ES.ISO8859-1
export LC_ALL

I ran the script and after that i started the aplication server. I tried my application and yes it works fine now, this is great. The only thing left is I want to know if i should include this lines in the /etc/profile so it works with all users or if I should put it in some other place.

Thanks.

I added the following lines to the /etc/profiles

LC_ALL=es_ES.ISO8859-1
export LC_ALL

It works fine, now when i use the locale command I get the following:

LANG=
LC_CTYPE="es_ES.ISO8859-1"
LC_NUMERIC="es_ES.ISO8859-1"
LC_TIME="es_ES.ISO8859-1"
LC_COLLATE="es_ES.ISO8859-1"
LC_MONETARY="es_ES.ISO8859-1"
LC_MESSAGES="es_ES.ISO8859-1"
LC_ALL=es_ES.ISO8859-1

I realize now that the configurations in /etc/default/init only work when you are working in the graphic environment.

Thanks p_saravanan for the tip.