是否可以使 JBoss JDBC 连接失效,以便不再从连接池重新提供连接?

发布于 2024-07-22 11:14:35 字数 344 浏览 2 评论 0原文

我遇到过这样的情况:JDBC 连接将其所附加的 Oracle 会话置于特定状态(即 DBMS_FLASHBACK 启用模式)。 此模式的退出可能会失败(至少理论上如此),这意味着会话错误地处于该状态。 在这种情况下,连接可以返回到池中,并由另一个线程获取,而 Oracle 会话仍处于 DBMS_FLASHBACK 启用模式。

我已经证明这确实会发生。 (JBoss 4.2.1)

理想的情况是在模式退出失败时捕获 SQLException,并将连接标记为“坏”,这样一旦它返回到池中,JBoss 就会销毁该连接并创建一个新的连接。一。

但我找不到任何方法来标记连接以立即销毁。 有谁知道有什么办法吗?

I have a circumstance where a JDBC connection places the Oracle session to which it is attached into a particular state (i.e. DBMS_FLASHBACK enabled mode). It's possible for the exit of this mode to fail (at least theoretically) which means that the session is left in the state erroneously. In this case, the connection can be returned to the pool, and obtained by another thread with the Oracle session still in DBMS_FLASHBACK enabled mode.

I have proved that would actually happen. (JBoss 4.2.1)

What would be ideal would be is to catch the SQLException when the mode exit fails, and mark the connection as "bad" so that once it was returned to the pool, JBoss would destroy the connection and create a new one.

But I can't find any way to mark the connection for immediate destruction. Does anyone know of a way?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

痴情 2024-07-29 11:14:35

您的 Oracle 数据库连接配置应包含异常排序器:

<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>

这会尝试确定何时发生异常,连接是否可以重用,或者必须断开连接。 这是尽最大努力的基础,并非在所有情况下都有效。 我对生产安装的偏好是将所有异常标记为致命。 为此,只需将异常排序器设置为 org.jboss.resource.adapter.jdbc.GenericExceptionSorter 即可。

Your Oracle database connection configuration should contain an exception sorter:

<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>

This attempts to determine when an exception occurs if the connection can be reused, or must be disconnected. This is on a best efforts basis, and doesn't work in every case. My preference for production installs is to mark all exceptions as fatal. To do this, simply set your exception sorter to org.jboss.resource.adapter.jdbc.GenericExceptionSorter.

时光沙漏 2024-07-29 11:14:35

这是一个很好的问题,我不知道完整的答案,但一些调查途径是从 JBoss 故障转移机制开始,它测试连接的有效性。 相关文档位于此处。 然后,在测试有效性的 SQL 中,如果插入的内容在连接处于 DBMS_FLASHBACK 启用模式时会失败,那么 JBoss 就会放弃该连接。 它可能会在下一个连接请求时进行测试,而不是在连接返回到池时进行测试,尽管这应该是可以接受的。

Its a good question, and I don't know the complete answer, but some avenues to investigate would be to start with the JBoss failover mechanism, where it tests the validity of the connection. The documentation for that is here. Then in the SQL that tests validity, if something could be put in that would fail if the connection is in the DBMS_FLASHBACK enabled mode, that should get JBoss to discard the connection. It probably tests on the next request for a connection, not when it is returned to the pool, although that should be acceptable.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文