You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Sascha Wehnert <Sa...@torexretail.de> on 2007/01/30 14:37:08 UTC
Return values in wrong sort order
Hi folks,
we encountered a problem (for us) in how Tomcat 5.5.20 returns requested data.
In our case we selected user data ordered by family name containing special polish
characters from an Oracle database. As soon as the familiy name starts with
a special character, the name gets listed at the bottom of the output and not in
alphabetical order.
If I run the same query on the database the values returned look pretty good. So I
assume my Tomcat instance was configured with the wrong settings. $LANG is set
to de_DE.UTF-8 and JAVA_OPTS includes “-Xms256m -Xmx512m -server -Dutil.language=de
-Djava.library.path=/opt/apr127/lib -Dfile.encoding=UTF-8”. All settings are placed in
catalina.sh, of course with an export command in front of them ;-)
Even if I change $LANG to pl_PL.UTF-8 or use –Dfile.encoding=UTF-8 it doesn’t change
anything about the sort order.
Am I missing here some JAVA options? Has anyone of you perhaps come across
a similar problem and could give me some pointer in the right direction?
regards,
Sascha
Re: Return values in wrong sort order
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Sascha,
Sascha Wehnert wrote:
> As soon as the familiy name starts with a special character, the name
> gets listed at the bottom of the output and not in alphabetical
> order.
>
> If I run the same query on the database the values returned look
> pretty good. So I assume my Tomcat instance was configured with the wrong settings.
You should check the locale (and character set) being used by your JDBC
connection. You may have to specify this as part of the URL.
Also note that your database is probably going to do ORDER BY sorting
differently than Java will if you use Collections.sort() to sort strings.
> $LANG is set to de_DE.UTF-8
You know that this is German, not Polish, right?
> and JAVA_OPTS includes “-Xms256m -Xmx512m -server -Dutil.language=de
I've never heard of using "-Dutil.language=de" for anything before. IF
you want to set the language of the JVM, you need to specify
- -Duser.language=de
and
- -Duser.country=DE
> Even if I change $LANG to pl_PL.UTF-8 or use –Dfile.encoding=UTF-8 it doesn’t change
> anything about the sort order.
Changing the file encoding will only change how Java converts bytes into
characters, and only when using the default language settings for the
JVM. I also do not believe that $LANG has any bearing on the locale
settings for the JVM.
Your problem is likely to be the JDBC driver settings. Since you are not
sorting in your Java code, then the database is to blame. Check your
connection settings to ensure that you are using the proper locale for
sorting, and I think you will end up with the sort order you want.
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFFv4tY9CaO5/Lv0PARArzxAKDD7Mjet4iqpNrxGjdv0Rak+an7HACglgoP
mEchN+exwKOVW5X86GvYYPQ=
=bsYL
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
AW: AW: Return values in wrong sort order
Posted by Sascha Wehnert <Sa...@torexretail.de>.
Hi David,
> -----Ursprüngliche Nachricht-----
> Von: David Delbecq [mailto:delbd@oma.be]
> Gesendet: Mittwoch, 31. Januar 2007 10:24
> An: Tomcat Users List
> Betreff: Re: AW: Return values in wrong sort order
[...]
> Unfortunately, the oracle thin driver are quite ... cumbersome to use.
> You will probably play by changing the JDBC url connection parameter,
> but the oracle doc is not very clear on how to build a connection URL
> with parameters. I have discovered here, for example, when using
> henplus, a command-line java sql application, that the driver was
> messing character encoding in java 1.4 but not in java 5 :/
>
> I found a few docs on the net on how to autmatically alter the user
> session when he connect and set his user language, this has nothing to
> do with java part but with defining a 'connection trigger' on the
> database. Unfortunately, i don't have those urls, you'll have to search
> yourself:)
>
> One thing worth trying. Install Henplus on same computer as tomcat is
> running, configure it to use oracle thin drivers, use the same JVM
> version as tomcat is using, connect to database and issue a query with
> a SORT clause. If it wrongly sorted, it's something to do with setting
> oracle language for connection. If it's correctly sorted, then that mean
> your webapplication is messing later the order of data and it's up to
> your developpers to fix it.
Thanks for the hint, I appreciate your help!
> http://henplus.sourceforge.net/
Thanks for the link, I'll give it a try.
[...]
Regards,
Sascha
Re: AW: Return values in wrong sort order
Posted by David Delbecq <de...@oma.be>.
En l'instant précis du 01/30/07 16:00, Sascha Wehnert s'exprimait en ces
termes:
> Hi David,
>
> thanks for your response.
>
>
>> -----Ursprüngliche Nachricht-----
>> Von: David Delbecq [mailto:delbd@oma.be]
>> Gesendet: Dienstag, 30. Januar 2007 14:43
>> An: Tomcat Users List
>> Betreff: Re: Return values in wrong sort order
>>
>> Looks to me liek a problem of the webapp, not a problem of tomcat.
>> The oracle thin driver have, i already noticed, to default to
>> america.american. You webapp will probably need to issue a few alter
>> session to enable special sorting rule. It is probably working on your
>> sqlplus client because it is setting correctly the session.
>>
>
> Is there any way I can temporarily change the behaviour of the Oracle thin driver? Just to test if this is the source of the issue. If it is, I need to talk to our developers to find a solution within our web application.
>
Unfortunately, the oracle thin driver are quite ... cumbersome to use.
You will probably play by changing the JDBC url connection parameter,
but the oracle doc is not very clear on how to build a connection URL
with parameters. I have discovered here, for example, when using
henplus, a command-line java sql application, that the driver was
messing character encoding in java 1.4 but not in java 5 :/
I found a few docs on the net on how to autmatically alter the user
session when he connect and set his user language, this has nothing to
do with java part but with defining a 'connection trigger' on the
database. Unfortunately, i don't have those urls, you'll have to search
yourself:)
One thing worth trying. Install Henplus on same computer as tomcat is
running, configure it to use oracle thin drivers, use the same JVM
version as tomcat is using, connect to database and issue a query with
a SORT clause. If it wrongly sorted, it's something to do with setting
oracle language for connection. If it's correctly sorted, then that mean
your webapplication is messing later the order of data and it's up to
your developpers to fix it.
http://henplus.sourceforge.net/
> Regards,
>
> Sascha
>
>
>> En l'instant précis du 01/30/07 14:37, Sascha Wehnert s'exprimait en ces
>> termes:
>>
>>> Hi folks,
>>>
>>>
>>>
>>> we encountered a problem (for us) in how Tomcat 5.5.20 returns requested
>>>
>> data.
>>
>>> In our case we selected user data ordered by family name containing
>>>
>> special polish
>>
>>> characters from an Oracle database. As soon as the familiy name starts
>>>
>> with
>>
>>> a special character, the name gets listed at the bottom of the output
>>>
>> and not in
>>
>>> alphabetical order.
>>>
>>>
>>>
>>> If I run the same query on the database the values returned look pretty
>>>
>> good. So I
>>
>>> assume my Tomcat instance was configured with the wrong settings. $LANG
>>>
>> is set
>>
>>> to de_DE.UTF-8 and JAVA_OPTS includes “-Xms256m -Xmx512m -server -
>>>
>> Dutil.language=de
>>
>>> -Djava.library.path=/opt/apr127/lib -Dfile.encoding=UTF-8”. All settings
>>>
>> are placed in
>>
>>> catalina.sh, of course with an export command in front of them ;-)
>>>
>>>
>>>
>>> Even if I change $LANG to pl_PL.UTF-8 or use –Dfile.encoding=UTF-8 it
>>>
>> doesn’t change
>>
>>> anything about the sort order.
>>>
>>>
>>>
>>> Am I missing here some JAVA options? Has anyone of you perhaps come
>>>
>> across
>>
>>> a similar problem and could give me some pointer in the right direction?
>>>
>>>
>>>
>>> regards,
>>>
>>>
>>>
>>> Sascha
>>>
>>>
>>>
>>>
>>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>
>
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
AW: Return values in wrong sort order
Posted by Sascha Wehnert <Sa...@torexretail.de>.
Hi David,
thanks for your response.
> -----Ursprüngliche Nachricht-----
> Von: David Delbecq [mailto:delbd@oma.be]
> Gesendet: Dienstag, 30. Januar 2007 14:43
> An: Tomcat Users List
> Betreff: Re: Return values in wrong sort order
>
> Looks to me liek a problem of the webapp, not a problem of tomcat.
> The oracle thin driver have, i already noticed, to default to
> america.american. You webapp will probably need to issue a few alter
> session to enable special sorting rule. It is probably working on your
> sqlplus client because it is setting correctly the session.
Is there any way I can temporarily change the behaviour of the Oracle thin driver? Just to test if this is the source of the issue. If it is, I need to talk to our developers to find a solution within our web application.
Regards,
Sascha
> En l'instant précis du 01/30/07 14:37, Sascha Wehnert s'exprimait en ces
> termes:
> > Hi folks,
> >
> >
> >
> > we encountered a problem (for us) in how Tomcat 5.5.20 returns requested
> data.
> >
> > In our case we selected user data ordered by family name containing
> special polish
> >
> > characters from an Oracle database. As soon as the familiy name starts
> with
> >
> > a special character, the name gets listed at the bottom of the output
> and not in
> >
> > alphabetical order.
> >
> >
> >
> > If I run the same query on the database the values returned look pretty
> good. So I
> >
> > assume my Tomcat instance was configured with the wrong settings. $LANG
> is set
> >
> > to de_DE.UTF-8 and JAVA_OPTS includes “-Xms256m -Xmx512m -server -
> Dutil.language=de
> >
> > -Djava.library.path=/opt/apr127/lib -Dfile.encoding=UTF-8”. All settings
> are placed in
> >
> > catalina.sh, of course with an export command in front of them ;-)
> >
> >
> >
> > Even if I change $LANG to pl_PL.UTF-8 or use –Dfile.encoding=UTF-8 it
> doesn’t change
> >
> > anything about the sort order.
> >
> >
> >
> > Am I missing here some JAVA options? Has anyone of you perhaps come
> across
> >
> > a similar problem and could give me some pointer in the right direction?
> >
> >
> >
> > regards,
> >
> >
> >
> > Sascha
> >
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
Re: Return values in wrong sort order
Posted by David Delbecq <de...@oma.be>.
Looks to me liek a problem of the webapp, not a problem of tomcat.
The oracle thin driver have, i already noticed, to default to
america.american. You webapp will probably need to issue a few alter
session to enable special sorting rule. It is probably working on your
sqlplus client because it is setting correctly the session.
En l'instant précis du 01/30/07 14:37, Sascha Wehnert s'exprimait en ces
termes:
> Hi folks,
>
>
>
> we encountered a problem (for us) in how Tomcat 5.5.20 returns requested data.
>
> In our case we selected user data ordered by family name containing special polish
>
> characters from an Oracle database. As soon as the familiy name starts with
>
> a special character, the name gets listed at the bottom of the output and not in
>
> alphabetical order.
>
>
>
> If I run the same query on the database the values returned look pretty good. So I
>
> assume my Tomcat instance was configured with the wrong settings. $LANG is set
>
> to de_DE.UTF-8 and JAVA_OPTS includes “-Xms256m -Xmx512m -server -Dutil.language=de
>
> -Djava.library.path=/opt/apr127/lib -Dfile.encoding=UTF-8”. All settings are placed in
>
> catalina.sh, of course with an export command in front of them ;-)
>
>
>
> Even if I change $LANG to pl_PL.UTF-8 or use –Dfile.encoding=UTF-8 it doesn’t change
>
> anything about the sort order.
>
>
>
> Am I missing here some JAVA options? Has anyone of you perhaps come across
>
> a similar problem and could give me some pointer in the right direction?
>
>
>
> regards,
>
>
>
> Sascha
>
>
>
>
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org