Old and beaten ORA-12705: Cannot access NLS data files or invalid environment specified and java Locale.setDefault()
I have a question that makes me crazy on my laptop i have oracle-xe 10.2.0 on ubuntu
DB Charset : AMERICAN_AMERICA.AL32UTF8
NLS_LANG=AMERICAN_AMERICA.AL32UTF8
public static void main(String[] args) throws Exception {
// Default locale before overwriting is ru_RU
// Locale.setDefault(new Locale("EN"));
//
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection(
"jdbc:oracle:thin:@localhost:1521:xe", "test", "test");
try {
// @machineName:port:SID, userid, password
Statement stmt = conn.createStatement();
try {
ResultSet rset = stmt
.executeQuery("select * from test");
try {
while (rset.next())
System.out.println(rset.getString(1)); // Print col 1
} finally {
try {
rset.close();
} catch (Exception ignore) {
}
开发者_如何学C }
} finally {
try {
stmt.close();
} catch (Exception ignore) {
}
}
} finally {
try {
conn.close();
} catch (Exception ignore) {
}
}
}
If i comment Locale.setDefault i have an ORA-12705: Cannot access NLS data files or invalid environment specified exception (default locale in this case stays ru_RU), but if i set default locale to EN, then everything is all right.
What can it mean? Why it is used Locale.getDefault value instead of NLS_LANG, like has written in every article about it?
Thanks
Please use these VM Options: -Duser.region=US -Duser.language=en -Duser.country=US
By default JDBC locale is determined from the JVM locale, NLS_LANG is ignored. Another way to change locale is specifying -Duser.language and -Duser.country command line arguments.
精彩评论