如何更改 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
相关文章