可以试试数据库级的trigger. Creating a Database Event Trigger: Example This example shows the basic syntax for a trigger to log all errors. The hypothetical PL/SQL block does some special processing for a particular error (invalid logon, error number 1017). This trigger is an AFTER statement trigger, so it is fired after an unsuccessful statement execution, such as unsuccessful logon.CREATE TRIGGER log_errors AFTER SERVERERROR ON DATABASE BEGIN IF (IS_SERVERERROR (1017)) THEN <special processing of logon error> ELSE <log error number> END IF; END;
查看当前的连接数 show parameter processes 默认150alter system set processes=1000 scope=spfile在重启试试
由于ora-00020较难模拟,直接模拟ORA-01017 Invalid user name/password; logon denied; 在sys下建立如下trigger.CREATE OR REPLACE TRIGGER log_errors AFTER SERVERERROR ON DATABASE declare v_num number; BEGIN IF (IS_SERVERERROR (1017)) THEN select t.VALUE into v_num from v$parameter t where t.NAME='processes'; RAISE_APPLICATION_ERROR(-20101, 'there has already exist '||v_num||' processes!'); END IF; END;使用sqlplus登入 C:\>sqlplus scott@orcl102/134SQL*Plus: Release 10.1.0.2.0 - Production on 星期四 11月 18 11:47:21 2010Copyright (c) 1982, 2004, Oracle. All rights reserved.ERROR: ORA-00604: error occurred at recursive SQL level 1 ORA-20101: there has already exist 150 processes! ORA-06512: at line 6 ORA-01017: invalid username/password; logon denied
Creating a Database Event Trigger: Example
This example shows the basic syntax for a trigger to log all errors. The hypothetical PL/SQL block does some special processing for a particular error (invalid logon, error number 1017). This trigger is an AFTER statement trigger, so it is fired after an unsuccessful statement execution, such as unsuccessful logon.CREATE TRIGGER log_errors AFTER SERVERERROR ON DATABASE
BEGIN
IF (IS_SERVERERROR (1017)) THEN
<special processing of logon error>
ELSE
<log error number>
END IF;
END;
show parameter processes 默认150alter system set processes=1000 scope=spfile在重启试试
其实,根据你的参数设置已经可以算出你的数据库连接数量了。
再一个可以通过系统进程进行统计。
在sys下建立如下trigger.CREATE OR REPLACE TRIGGER log_errors AFTER SERVERERROR ON DATABASE
declare
v_num number;
BEGIN
IF (IS_SERVERERROR (1017)) THEN
select t.VALUE into v_num from v$parameter t where t.NAME='processes';
RAISE_APPLICATION_ERROR(-20101, 'there has already exist '||v_num||' processes!');
END IF;
END;使用sqlplus登入
C:\>sqlplus scott@orcl102/134SQL*Plus: Release 10.1.0.2.0 - Production on 星期四 11月 18 11:47:21 2010Copyright (c) 1982, 2004, Oracle. All rights reserved.ERROR:
ORA-00604: error occurred at recursive SQL level 1
ORA-20101: there has already exist 150 processes!
ORA-06512: at line 6
ORA-01017: invalid username/password; logon denied