在 Java 应用程序中使用 dbcp 连接池设置 DB2 客户端审核信息

发布于 2024-08-05 02:49:44 字数 658 浏览 4 评论 0原文

我正在 Tomcat 5.5 上开发 Java 应用程序,使用 JNDI 连接到带有 JDBC 3.0 驱动程序的共享 dbcp 连接池以及 zOS 上的 DB2 8 以及 LUW 上的 DB2 9。在我的应用程序中,我使用 org.springframework.jndi.JndiObjectFactoryBean 获取数据源并将其输入 org.springframework.jdbc.core.simple.SimpleJdbcTemplate 来运行查询。到目前为止,这是一个相当好的解决方案,但我们的 DBA 要求我们提供更好的粒度来审计 SQL 性能。目前,所有 portlet 和应用程序都使用相同的连接池来连接到数据库,区分应用程序的唯一方法是将 SQL 运行与每个应用程序中的 SQL 进行匹配。我们不想为每个应用程序创建单独的池。 DB2 在驱动程序的 DB2Connection 上提供了多种方法,允许我们设置审计信息。

设置DB2ClientApplicationInformation
设置DB2ClientUser
设置DB2ClientWorkstation
设置DB2ClientAccountingInformation

我的问题是...在连接池的连接上设置这些值的最佳方法是什么。我是否需要访问底层连接才能设置这些值?在将连接返回到池之前我应该​​清除它们吗?有人有代码示例吗?

I'm developing Java apps on Tomcat 5.5 using JNDI to connect to shared dbcp connection pools with JDBC 3.0 drivers and DB2 8 on zOS and also DB2 9 on LUW. In my app, I use org.springframework.jndi.JndiObjectFactoryBean to get the dataSource and feed it into an org.springframework.jdbc.core.simple.SimpleJdbcTemplate to run the queries. This has been a fairly good solution so far, but our DBAs are requesting that we provide better granularity for auditing SQL performance. Currently, all portlets and apps use the same connection pool to connect to the database and the only way to distinguish between apps is to match the SQL run with the SQL in each app. We don't want to create seperate pools for each app. DB2 provides several methods on their DB2Connection from the driver that allow us to set audit information.

setDB2ClientApplicationInformation
setDB2ClientUser
setDB2ClientWorkstation
setDB2ClientAccountingInformation

My question is... what's the best way to set these values on a connection from a connection pool. Do I need to access the underlying connection in order to set these values? Should I clear them before returning the connection to the pool? Does anyone have code examples?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文