JDBC 瘦驱动程序的 NLS_LANG 设置?

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

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

SQL to Generate Periodic Snapshots from Transactions Table(用于从事务表生成定期快照的SQL)
MyBatis support for multiple databases(MyBatis支持多个数据库)
Oracle 12c SQL: Missing column Headers in result(Oracle 12c SQL:结果中缺少列标题)
SQL query to find the number of customers who shopped for 3 consecutive days in month of January 2020(查询2020年1月连续购物3天的客户数量)
How to get top 10 data weekly (This week, Previous week, Last month, 2 months ago, 3 month ago)(如何每周获取前十大数据(本周、前一周、上个月、2个月前、3个月前))
Select the latest record for an Id per day - Oracle pl sql(选择每天ID的最新记录-Oracle pl SQL)