JDBC 瘦驱动程序的 NLS_LANG 设置?
我使用的是精简版 Oracle JDBC 驱动程序 10.2.0 (ojdbc14.jar).我想手动配置它的 NLS_LANG 设置.有办法吗?
目前,它从 VM 变量 user.language(通过设置当前语言环境或从系统环境启动时自动设置)获取此设置.
当用户将应用程序语言环境切换到 Oracle JDBC 驱动程序(例如 mk_MK)不支持的语言环境时,这是一个问题.在这种情况下,下次我获取连接时会出现以下异常:
<前>ORA-00604: 递归 SQL 级别 1 发生错误ORA-12705: 无法访问 NLS 数据文件或指定的环境无效我可以在获取连接之前即时更改区域设置,然后来回切换回用户选择的区域设置,但这似乎不优雅且效率低下.
解决方案NLS_LANG 设置派生自 java.util.Locale .因此,您需要在连接前进行类似的调用:
Locale.setDefault(Locale.<您的语言环境>);
I am using the thin Oracle JDBC driver ver 10.2.0 (ojdbc14.jar). I would like to configure its NLS_LANG setting manually. Is there a way?
Currently it fetches this setting from the VM variable user.language (which is set automatically by setting the current locale, or on startup from the system environment).
This is a problem when the users switch the application locale to a one that is unsupported by the Oracle JDBC driver (e.g. mk_MK). In this case, the next time I fetch a connection I get the following exception:
ORA-00604: error occurred at recursive SQL level 1 ORA-12705: Cannot access NLS data files or invalid environment specified
I can change the locale on the fly just before I fetch the connection and switch back to the user's selected one back and forth, but this seems unelegant and unefficient.
解决方案The NLS_LANG settings are derived from the java.util.Locale . Therefore, you will need to make a call similar to this before connecting:
Locale.setDefault(Locale.<your locale here>);
相关文章