NLS_LANG setting for JDBC thin driver?(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>);
这篇关于JDBC 瘦驱动程序的 NLS_LANG 设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:JDBC 瘦驱动程序的 NLS_LANG 设置?


基础教程推荐
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
- 在多列上分布任意行 2021-01-01
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
- oracle区分大小写的原因? 2021-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01