我尝试在jdbc中设置NLS_DATE_FORMAT,它似乎没有任何作用.
我的代码:
//...
Connection conn = ods.getConnection();
Statement stat = conn.createStatement();
stat.execute("alter session set NLS_DATE_FORMAT='YYYY-DD-MM'");
ResultSet rs = stat.executeQuery("select date_column from test_table");
System.out.println(rs.getString(1)); // *** new format not effective here ***
//...
经过一番阅读.我知道NLS_DATE_FORMAT在JDBC驱动程序中进行了硬编码.这个对吗 ?由此得出的结论:
Language and Territory
The Thin driver obtains language and territory settings (NLS_LANGUAGE and NLS_TERRITORY) from the Java locale in the JVM user.language property. The date format (NLS_DATE_FORMAT) is set according to the territory setting.
所以我尝试了这个:
Locale.setDefault(new Locale("en", "US"));
Connection conn = ods.getConnection();
<