使用DB Link的Java查询不会关闭Db Link连接 [英] Java query with DB Link does not close the Db Link connection

查看:106
本文介绍了使用DB Link的Java查询不会关闭Db Link连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个连接到数据库A的Java代码.数据库A具有到数据库B的DB链接. 这两个数据库都是oracle.

I have a Java code that connects to Database A. Database A has DB link to Database B. Both database are oracle.

我与数据库A建立了JPA连接 然后,我运行从DAtabase A到数据库B中的表的联接查询 然后关闭与数据库A的连接 简单的代码.

I make a JPA connection to Database A Then I run a query from joining a table from DAtabase A to table in Database B Then Close connection to Database A Simple code.

我仍然看到数据库B上的DB链接连接已打开.它没有关闭.知道为什么吗? 我以为应该在内部处理好吗?

I am still seeing the DB link connections on Database B is open. It is not closing. Any idea why? I am assuming that it should be internally handled right?

有想法吗?

推荐答案

如果关闭与数据库的连接,则会自动关闭所有数据库链接连接.

If you close a connection to the database all database link connections are automatically closed.

因此,如果您观察到打开的链接会话,则它们源自其他尚未关闭的连接.

So if you observes open link sessions, they stem from other not yet closed connections.

出于性能原因,数据库链接连接不会在每个分布式查询后立即关闭,而是有意地保持打开状态,以便在潜在的下一条语句中重新使用.

The database link connection is from performance reasons not closed immediately after each distributed query, but is intentionally left open to be reused in the potential next statement.

无论如何,您都可以使用以下任一方式专门关闭链接连接

Anyway you can excplicitely close the link connection using a call of either

 alter session close database link  link_name

DBMS_SESSION.CLOSE_DATABASE_LINK('link_name')

此处说明.这主要是在您达到最大

es illustrated here. This is mainly done in case you hit the limit of maximal open links

这篇关于使用DB Link的Java查询不会关闭Db Link连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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