db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stanley Bradbury <Stan.Bradb...@gmail.com>
Subject Re: Confustion about locale and error messages
Date Thu, 08 Nov 2007 23:42:32 GMT
The confusing paragraph is old information and lists the old URL 
attribute: /locale=ll_CC/  rather than the new URL attribute 
/territory=ll_CC./  This should be corrected and some the behavior it 
tries to convey may not have made it into Derby??  The tools guide seems 
to have a good explanation, however.

The confusing paragraph also appears to me to be performing a mash-up of 
two different topics - database locale and Tool locale.  The two should 
be discussed in separate sections.  Someone who has delved into the code 
could probably clarify further but that is not me.  All I can provide is 
demonstrations - it will take a better witter than I to describe this 
verbally.

Some important background for what follows:

1) There is the database locale (aka territory=ll_CC) that determines 
(but only a database create time) what supported message library (e.g. 
derbyLocale_de_DE.jar ) is loaded into the database.   These are the 
messages associated with the SQLExceptions presented by the Derby engine 
and can be displayed using: 
                   SELECT * FROM SYSCS_DIAG.ERROR_MESSAGES
  These stay with the database regardless of System JVM locale setting.  
If not specified the System JVM setting is used.

2) The tool session locale (The JVM system locale):  This is application 
dependant and will almost always be the System JVM default locale - it 
changes some messages that IJ presents to localized versions like the 
welcome/IJ version string, the  'row selected' message, the tag ERROR 
seems to get truncated but the message indicating where a syntax error 
is found seems to always be in English (at least on my machine).

and for IJ, with "localizeddisplay on" the JVM/tools session local 
determines the localized display format for numbers, dates, times, and 
timestamps.  It does not change the IJ generated error messages as far 
as I can tell.

Based on my experimenting with databases created with different 
territories here is what appears to happen.
NOTE: my default System locale is en_US

java org.apache.derby.tools.ij
ij> connect 'adf:adf:aer';
ERROR 08001: No suitable driver                              <<- english 
message for application level / IJ error 08001
ij> connect 'jdbc:derby:mxdb;create=true;territory=es_MX';       
<<-create a Spanish MX database
ij> select * from fred;
ERROR 42X05: La tabla/vista 'FRED' no existe.                        <<- 
get Spanish MX error messages for Derby errors
ij> connect 'jdbc:derby:deDEdb;create=true;territory=de_DE';    
<<-create a German database
ij(CONNECTION1)> select * from fred;
ERROR 42X05: Die Tabelle/Ansicht 'FRED' ist nicht vorhanden.    <<- get 
German error messages for Derby errors
ij(CONNECTION1)> localizeddisplay on;
ij(CONNECTION1)> values current_date;
1
------------------
November 8, 2007                                                   <<-  
IJ localizeddisplay US english error messages
1 row selected                                                           
<<-  IJ locale rowcounts: US english
ij(CONNECTION1)> connect 'jdbc:derby:defaultLocaledb;create=true';
ij(CONNECTION2)> select * from fred;
ERROR 42X05: Table/View 'FRED' does not exist.  <<- get US english error 
messages for Derby errors
ij(CONNECTION2)> localizeddisplay on;
ij(CONNECTION2)> values current_date;
1
------------------
November 8, 2007                                                 <<-  IJ 
localizeddisplay US english error messages
1 row selected                                                     <<-  
IJ locale rowcounts: US english

  %%%%%  NOW I start a new IJ session and explicitly set the JVM default 
locale by specifying the variables: 
user.language     
user.region   

C:\>java -Duser.region=BR -Duser.language=pt org.apache.derby.tools.ij
vers?o ij 10.3                                                        
<<-  IJ  pt_BR message
ij> connect 'adf:adf';
ERRO 08001: No suitable driver    <<-  IJ pt_BR message
ij> connect 'jdbc:derby:defBRdb;create=true';             <<-create a 
database  w/ JVM default (set:  pt_BR)
ij> select * from fred;
ERRO 42X05: A tabela/vis?o 'FRED' n?o existe.             <<- get  pt_BR 
messages for Derby errors
ij> localizeddisplay on;
ij> values current_date;
1
-----------------------
8 de Novembro de 2007                                 <<-  IJ 
localizeddisplay pt_BR
1 linha selecionada                                           <<-  IJ 
locale rowcounts: pt_BR
ij> localizeddisplay off;
ij> values current_date;
1
----------
2007-11-08                                                     <<-  IJ 
standard display (java format)
1 linha selecionada                                          <<-  IJ 
locale rowcounts: pt_BR

ij> connect 'jdbc:derby:deDEdb';                                 <<-  
NOW connect to the GERMAN database
ij(CONNECTION1)> select * from fred3;
ERRO 42X05: Die Tabelle/Ansicht 'FRED3' ist nicht vorhanden.      <<- 
get German error messages for Derby errors
ij(CONNECTION1)> values current_date;
1
----------
2007-11-08                                                    <<-  IJ 
standard display (java format)
1 linha selecionada                                          <<-  IJ 
locale rowcounts: pt_BR
ij(CONNECTION1)> localizeddisplay on;
ij(CONNECTION1)> values current_date;
1
-----------------------
8 de Novembro de 2007                             <<-  IJ 
localizeddisplay pr_BT
1 linha selecionada                                       <<-  IJ locale 
rowcounts: pt_BR

ij(CONNECTION1)>
    connect 'jdbc:derby:deDEdb;territory=pt_BR';           <<-  NOW 
connect to the GERMAN database specifying pt_BR
ij(CONNECTION2)> select * from fred3;
ERRO 42X05: Die Tabelle/Ansicht 'FRED3' ist nicht vorhanden.  <<- get 
German error messages NOT pt_BR
                                                                                         
                  
- territory set a DB creatiton
ij(CONNECTION2)> slect * from fred3;
ERRO 42X01: Syntaxfehler: Encountered "slect" at line 1, column 1.  <<- 
Mixed message: DB territory (German) ane English

Good luck with this - hope it isn't too much.  I will be happy to do 
other testing if you have questions related to behavior.

Laura Stewart wrote:
> Is there anyone that explain how locale works with Derby error messages?
>
> On 10/29/07, Laura Stewart <scotsmatrix@gmail.com> wrote:
>   
>> Hi - Derby-2188 is about locale info within Derby.  One file,
>> cdevin55108.html, has some confusing info about locale and error
>> messages.
>>
>> Below is from Mamta's comment on this issue and I am hoping someone on
>> derby-dev can address these issues for us.
>>
>> cdevin55108.html says
>> "For example, Derby explicitly supports Spanish-language error
>> messages. If a database's locale is set to one of the Spanish-language
>> locales, Derby returns error messages in the Spanish language." So
>> this seems to indicate that locale of the database will determine the
>> language of the error messages. But the line below seems to say that
>> locale of the database has nothing to do with language of the error
>> messages. "The locale of the database is set by the territory=ll_CC
>> attribute when the database is created. However, **the locale of the
>> error messages and tools is not determined by the locale of the
>> database**. The locale of the error messages and tools is determined
>> by the default system locale. This means that it is possible to create
>> a database with a non-default locale. In such a case, error messages
>> are not returned in the language of the locale of the database but are
>> returned in the language of the default locale instead."
>>
>> Thanks!
>> --
>> Laura Stewart
>>
>>     
>
>
>   



Mime
View raw message