ラップトップで夢中になる質問があります。ubuntu で oracle-xe 10.2.0 を使用しています。
DB 文字セット : 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: Cannot access NLS data files or invalid environment specified例外 (この場合のデフォルト ロケールは ru_RU のまま) が発生しますが、デフォルト ロケールを EN に設定すると、すべて問題ありません。
それはどういう意味ですか?それについてのすべての記事に書かれているように、NLS_LANG の代わりに Locale.getDefault 値が使用されるのはなぜですか?
ありがとう