Java query with DB Link does not close the Db Link connection

点点圈 提交于 2021-01-28 19:49:47

问题


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

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.

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?

Thoughts?


回答1:


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

or

DBMS_SESSION.CLOSE_DATABASE_LINK('link_name')

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



来源:https://stackoverflow.com/questions/61330499/java-query-with-db-link-does-not-close-the-db-link-connection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!