我有一个问题让我在笔记本电脑上发疯 我在 ubuntu 上有 oracle-xe 10.2.0
数据库字符集: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) {
}
}
} 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,就像在每篇文章中都写过一样?
谢谢