如何更改 oracle jdbc 客户端的默认 nls_date_format [英] How to change default nls_date_format for oracle jdbc client

查看:30
本文介绍了如何更改 oracle jdbc 客户端的默认 nls_date_format的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Oracle 10.2 XE 上定义了全局 nls_date_format 如下:

I have defined the global nls_date_format on Oracle 10.2 XE as follows:

alter system set nls_date_format='YYYY-MM-DD HH24:MI:SS' scope=spfile;

在 Windows 上连接时,客户端使用会话特定格式覆盖它,因此我需要在每个会话开始时运行此行:

When connecting on Windows, the clients override it with session specific format, so I need to run this line at the beginning of every session:

alter session set nls_date_format='YYYY-MM-DD HH24:MI:SS';

但是,我有一些无法更改的自定义代码(jdbc代码,使用ojdbc14.jar),因此在接收连接时无法执行此行.有没有办法为所有 jdbc 连接更改 nls_date_format 的默认值?也许在连接字符串中添加一些东西,或者一些我可以使用的环境变量?

However, I have some custom code that I can't change (jdbc code, using ojdbc14.jar), so I can't execute this line when receiving the connection. Is there a way to change the default value of nls_date_format for all jdbc connections? Perhaps adding something to the connection string, or some environment variable that I can use?

顺便说一句,sqlplus 和 sqldeveloper 也用自己的格式覆盖了服务器的格式,但我发现了如何更改它们的默认值,所以问题仅在于 jdbc 连接.

By the way, sqlplus and sqldeveloper also override the server's format with their own, but I found out how to change their defaults, so the problem is only with jdbc connections.

推荐答案

在登录后触发器中设置 nls 日期格式

Set nls date format in an after logon trigger

这篇关于如何更改 oracle jdbc 客户端的默认 nls_date_format的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆