问题
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