Set locale in Oracle connection

In my company product, we extract results one page from the database. Because of this, all filtering and sorting must be done in the database. One problem is encoded values. For filtering and sorting to work correctly, code values ​​must be translated to locally defined labels in the request.

My plan is to use a table similar to the following: t_code_to_label (type varchar2 (10), locale varchar2 (10), code varchar2 (10), label varchar2 (50)) The first three columns are the main (unique) key.

When using this table you will see something like this

select ent.name, ent.ent_type, entlabel.label as ent_type_label from t_entitlements ent join t_code_to_label entlabel on entlabel.type='entlabel' and entlabel.locale=currentLocale() and entlabel.code=ent.ent_type

The problem is that currentLocale () is what I came up with. How can I do something on the Java side of the JDBC connection to set the locale for the Connection object that I have, which I can read on the Oracle side in a simple function. Ideally, this is true support for the Oracle language, but I cannot find such a thing.

I am using Oracle 10g and 11g.

+3
source share
1 answer

Are you talking about setting up an NLS_LANGUAGEOracle database? Could you (on the client side) dictate the use of a specific NLS_LANGUAGEOracle database?

Then perhaps this would work: Install Oracle NLS_LANGUAGE from java to webapp

If you want to have “all American” sessions, you could do something like:

ALTER SESSION SET NLS_LANGUAGE= 'AMERICAN' NLS_TERRITORY= 'AMERICA' 
                  NLS_CURRENCY= '$' NLS_ISO_CURRENCY= 'AMERICA' 
                  NLS_NUMERIC_CHARACTERS= '.,' NLS_CALENDAR= 'GREGORIAN' 
                  NLS_DATE_FORMAT= 'DD-MON-RR' NLS_DATE_LANGUAGE= 'AMERICAN' 
                  NLS_SORT= 'BINARY'
+6

All Articles