在JDBC for Oracle中设置客户端信息 [英] setting Client Info in JDBC for Oracle

查看:728
本文介绍了在JDBC for Oracle中设置客户端信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个需要审核的Java应用程序(显然我需要一种可以使用应用程序名称识别应用程序的方法)。我用Google搜索并发现ojdbc14有方法 .setClientInfo ,它允许使用自定义名称注册应用程序,所以我试图让它工作但我收到以下错误:

I have a Java application which needs to be audited (so obviously I need a way in which the app can be identified with the application name). I googled and found that ojdbc14 has the method .setClientInfo which allows registering the application with a customized name, so I am trying to get it work but I get the following error:


线程main中的异常java.lang.AbstractMethodError:
oracle.jdbc.driver.T4CConnection.setClientInfo(Ljava / lang / String; Ljava / lang / String;)V

Exception in thread "main" java.lang.AbstractMethodError: oracle.jdbc.driver.T4CConnection.setClientInfo(Ljava/lang/String;Ljava/lang/String;)V

我在oracle 10g express中使用ojdbc14。如果我没有设置该行:

I am using ojdbc14 with oracle 10g express. If I do not set the line:

connection.setClientInfo("ApplicationName","Customers");

它工作得很好....通过检查审计信息我可以看到oracle得到了应用程序名称:OS_program_name = JDBC瘦客户端,但我需要一种方法来更改它以获得自定义名称。

it works pretty well ....and by checking the audit info I can see that oracle gets the application name:OS_program_name=JDBC Thin Client, but I need a way to change it for a customized name.

通过取消注释应该设置应用程序名称的那一行它返回上面的错误。

By uncommenting that line which is supposed to set the application name it returns the error above.

每个oracle文档该方法可用于 Connection 对象。您是否知道如何解决此问题?

Per oracle documentation that method is available for a Connection object. Do you have any idea how to solve this issue?

推荐答案

对于AbstractMethodError,请检查为什么我会得到java.lang.AbstractMethodError尝试在db中加载blob时?

For AbstractMethodError, please check Why do I get java.lang.AbstractMethodError when trying to load a blob in the db?

为了区分Oracle中的连接,可以使用下面的示例代码:

In order to distinguish your connections in Oracle you can use this sample code below:

Properties jdbcProperties = new Properties();

this.jdbcProperties.put("user", userName);
this.jdbcProperties.put("password", password);
this.jdbcProperties.put("v$session.program", "YourApplicationName");
DriverManager.getConnection(url, jdbcProperties);

然后通过对连接的程序列进行分组来检查v $ session ..

then check v$session by grouping against program column for your connections..

这篇关于在JDBC for Oracle中设置客户端信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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