oracle Old and ORA12705:无法访问NLS数据文件或指定的环境和java语言环境无效。setDefault()
我有个问题让我发疯 在我的笔记本电脑上,我在ubuntu上安装了oracle xe 10.2.0
DB Charset:美国的。AL32UTF8
NLS_LANG=美国。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) {
}
}
}
如果我评论语言环境。setDefault我有一个ORA-12705:无法访问NLS数据文件或无效的环境指定异常(本例中的默认语言环境保持ru_-ru),但如果我将默认语言环境设置为EN,则一切正常
这意味着什么?为什么在当地使用它。getDefault值而不是NLS_LANG,就像在每篇文章中写的那样
谢谢
# 1 楼答案
默认情况下,JDBC语言环境由JVM语言环境确定,NLS_LANG被忽略。更改区域设置的另一种方法是指定-Duser。语言和语言-杜塞。国家/地区命令行参数
# 2 楼答案
请使用以下虚拟机选项: -杜塞。地区=美国-杜塞尔。语言=英语。国家=美国