ORA-12705旧版和旧版:无法访问NLS数据文件或指定的环境和java语言环境无效。setDefault()
我有个问题让我发疯 在我的笔记本电脑上,我在ubuntu上安装了OracleXe10.2.0 DB字符集:AMERICAN_AMERICA.AL32UTF8ORA-12705旧版和旧版:无法访问NLS数据文件或指定的环境和java语言环境无效。setDefault(),java,oracle,locale,ora-12705,Java,Oracle,Locale,Ora 12705,我有个问题让我发疯 在我的笔记本电脑上,我在ubuntu上安装了OracleXe10.2.0 DB字符集: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
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) {
}
}
} finally {
try {
stmt.close();
} catch (Exception ignore) {
}
}
} finally {
try {
conn.close();
} catch (Exception ignore) {
}
}
}
NLS_LANG=美国_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) {
}
}
} finally {
try {
stmt.close();
} catch (Exception ignore) {
}
}
} finally {
try {
conn.close();
} catch (Exception ignore) {
}
}
}
如果我注释Locale.setDefault,我就有一个ORA-12705:无法访问NLS数据文件或无效的环境指定异常(本例中的默认区域设置为ru_-ru),但如果我将默认区域设置为EN,则一切正常
这意味着什么?为什么使用Locale.getDefault值而不是NLS_LANG,就像在每篇文章中所写的那样
谢谢默认情况下,JDBC语言环境由JVM语言环境确定,NLS_LANG被忽略。更改区域设置的另一种方法是指定-Duser.language和-Duser.country命令行参数。请使用以下VM选项: -Duser.region=US-Duser.language=en-Duser.country=US