Cause: The maximum number of active connections to remote databases per user
login has been reached.
Action: If the user has no open cursors, the current SQL statement accesses
more than the maximum allowed remote databases.
Otherwise, the user may free remote database connections by closing
all cursors that access the databases.
If this occurs often, consider increasing the value of the
initialization parameter OPEN_LINKS, which controls the maximum number
of concurrent open connections to remote databases per user process.
原因:最大活动连接的数超过设置
动作:如果用户没有使用游标,则正在运行的sql命令,使用的数据库连接超过允许的的最大数,
如果用户使用了游标,用户可以通过关闭访问的数据库的所有游标,来释放远程数据库连接,
如果此问题经常发生,考虑增加open_links参数,该参数控制每个用户进程允许打开的最大远程数据库连接数
百度给出的解答,
SQL> show parameter open_links;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
open_links integer 10
open_links_per_instance integer 4
Oracle默认是4:
SQL> alter system set open_links=10 scope=spfile;
重启下数据库就好了。
问题,用户并不一定有权限去操作,上述方式仅仅使用了第二种处理方式,关闭远程数据库连接的方式没有涉及
其实解决很简单。
对于活动的连接,commit或回滚就会断开活动的连接
SQL> select * from v$dblink;
DB_LINK OWNER_ID LOGGED_ON HETEROGENEOUS PROTOCOL OPEN_CURSORS IN_TRANSACTION UPDATE_SENT COMMIT_POINT_STRENGTH
-------------------------------------------------------------------------------- ---------- --------- ------------- -------- ------------ -------------- ----------- ---------------------
LNK_YYBCV1
DB_LINK OWNER_ID LOGGED_ON HETEROGENEOUS PROTOCOL OPEN_CURSORS IN_TRANSACTION UPDATE_SENT COMMIT_POINT_STRENGTH
-------------------------------------------------------------------------------- ---------- --------- ------------- -------- ------------ -------------- ----------- ---------------------
LNK_YYBCV1
使用命令关闭打开的远程数据库连接,数据库连接不用加单引号
SQL> alter session close DATABASE LINK lnk_yybcv1;
Session altered
Session altered
如果在存储过程中,数据库连接需要加单引号-字符串。
dbms_session.close_database_link(' lnk_yybcv1');
抱怨一句,百度出来的东西真不好用。