---
title: "转：TNS-12519与processes参数设置;jdbc 连接oracle 报 ORA-12519"
author: "Kenny.Lee"
date: "2011-08-05T17:11:15Z"
tags: []
categories: ["数据库"]
slug: "tns-12519-processes-jdbc-oracle-ora-12519"
draft: false
lastmod: "2011-08-05T17:11:15Z"
id: 1141206
url: "https://kennylee26.iteye.com/blog/1141206"
---

转：TNS-12519与processes参数设置;jdbc 连接oracle 报 ORA-12519, TNS:no appropriate service handler found 问题解决

这几天项目中进行大批量数据导入时，在运行一段时间后报如下异常：

java.sql.SQLException: Listener refused the connection with the following error:  
ORA-12519, TNS:no appropriate service handler found

找了些网友的解决策略，贴上来，等自己遇到的解决后再做总结.

ORA-12519, TNS:no appropriate service handler found  
url：[http://windows9834.blog.163.com/blog/static/273450042009102511540240/](http://windows9834.blog.163.com/blog/static/273450042009102511540240/)

Oracle 2009-11-25 11:54:00

ORA-12519: TNS:no appropriate service handler found 的解决

有时候连得上数据库,有时候又连不上.

可能是数据库上当前的连接数目已经超过了它能够处理的最大值.

SQL&gt; select count(\*) from v$process;--当前连接数  
     COUNT(\*)  
     63  
SQL&gt; select value from v$parameter where name = 'processes' --数据库允许的最大连接数  
VALUE  
500

修改最大连接数:  
SQL&gt; alter system set processes = 300 scope = spfile;

重启数据库:  
SQL&gt; shutdown immediate;  
SQL&gt; startup;

--查看当前有哪些用户正在使用数据  
SELECT osuser, a.username,cpu\_time/executions/1000000||'s', sql\_fulltext,machine   
from v$session a, v$sqlarea b  
where a.sql\_address =b.address order by cpu\_time/executions desc;

--快速删除不活动进程  
set heading off  
spool on  
select p.SPID from v$session s,v$process p where s.paddr= p.addr and s.machine='woogle';  
spool off  
set serveroutput on ;  
declare  
v\_sid number;  
v\_serial number;  
v\_sql varchar2(200) ;  
CURSOR cur\_session is  
   select sid, serial# from v$session where machine='woogle';  
begin  
open cur\_session ;  
fetch cur\_session into v\_sid , v\_serial ;  
while cur\_session%found  
loop  
dbms\_output.put\_line(v\_sid||' killed!') ;  
v\_sql:= 'alter system kill session '||''''||v\_sid||','||v\_serial||'''';  
execute immediate v\_sql ;  
fetch cur\_session into v\_sid , v\_serial ;  
end loop ;  
close cur\_session ;  
end ;  
/

Linux 下快速删除不活动进程  
#!/bin/bash

tmpfile=/tmp/tmp.$$

sqlplus ' / as sysdba' &lt;&lt; EOF

set heading off  
spool on  
spool $tmpfile  
select p.SPID from v$session s,v$process p where s.paddr= p.addr and s.STATUS='SNIPED';  
spool off  
set serveroutput on ;  
declare  
v\_sid number;  
v\_serial number;  
v\_sql varchar2(200) ;  
CURSOR cur\_session is  
   select sid, serial# from v$session where STATUS='SNIPED';  
begin  
open cur\_session ;  
fetch cur\_session into v\_sid , v\_serial ;  
while cur\_session%found  
loop  
dbms\_output.put\_line(v\_sid||' killed!') ;  
v\_sql:= 'alter system kill session '||''''||v\_sid||','||v\_serial||'''';  
execute immediate v\_sql ;  
fetch cur\_session into v\_sid , v\_serial ;  
end loop ;  
close cur\_session ;  
end ;  
/  
OERR: ORA-12519 TNS:no appropriate service handler found

url：[http://blog.csdn.net/wyzxg/archive/2008/03/06/2154274.aspx](http://blog.csdn.net/wyzxg/archive/2008/03/06/2154274.aspx)

2008/03/06  
skate

今天下午,开发人员突然说不能连接数据库了,提示相关的错误

 

OERR: ORA-12519 TNS:no appropriate service handler found

客户端连接间歇性失败，报错ORA-12519

Cause: the listener could not find any available service handlers that are   
       appropriate for the client connection.

Action: run "lsnrctl services" to ensure that the instance(s) have registered   
        with the listener, and are accepting connections. 检查lsnrctl service ，instance已经注册，  
状态显示ready时，可以连接。

When the listener believes the current number of connections has reached maximum load,   
it may set the state of the service handler for an instance to "blocked" and begin refusing   
incoming client connections with either of the following errors: ora-12519 or ora-12516

采用服务动态注册的方式，由PMON 通过SERVICE\_UPDATE 来得到目前连接情况，但SERVICE\_UPDATE 有时间间隔，  
所以，listener显示的连接数和当前实际的连接数可能不同。

查询解决方法:

查看一下数据库现有的进程数，是否已经达到参数processes的大小。

1.select count(\*) from v$process;                         取得数据库目前的进程数。  
2.select value from v$parameter where name = 'processes'; 取得进程数的上限。  
3.如已达到上限，修改initSID.ora中的processes的大小。  
4.重新启动数据库到nomount状态下，执行create spfile from pfile; 并startup open。

查询数据库自启动以来最大的并发数量

select * from v$license

本文来自CSDN博客，转载请标明出处：[http://blog.csdn.net/wyzxg/archive/2008/03/06/2154274.aspx](http://blog.csdn.net/wyzxg/archive/2008/03/06/2154274.aspx)

 

ORA-12519: TNS:no appropriate service handler found解法  
url：[http://tsaijemmy.spaces.live.com/blog/cns!4AD532D0CD18A21D!680.entry](http://tsaijemmy.spaces.live.com/blog/cns!4AD532D0CD18A21D!680.entry)  
ORA-12519: TNS:no appropriate service handler found解法  
ORA-12519: TNS:no appropriate service handler found (用戶端連接間歇性失敗)，有時會連得上有時連不上，可能是資料庫上當前的連接數目已經超過了它能夠處理的最大值。  
select count(\*) from v$process --當前的連接數  
select value from v$parameter where name = 'processes' --資料庫允許的最大連接數  
修改最大連接數:  
alter system set processes = 300 scope = spfile;  
重啟資料庫:  
shutdown immediate;  
startup;  
\--查看當前有哪些用戶正在使用資料  
SELECT osuser, a.username,cpu\_time/executions/1000000||'s', sql\_fulltext,machine from v$session a, v$sqlarea b where a.sql\_address =b.

\--------------------------------------------------------------------------------

還沒完，這問題是在C3P0遇到的，經過另篇文章查到，上面的錯誤是由於Oracle Express 10g的預設配置連接數只有20，而在hibernate.cfg.xml配置使用c3p0連接池的最大連接數遠遠超過了這個資料庫允許的數量，因此但頻繁的去連接資料庫的時候，無法獲得連接，資料庫Listner就直接拒絕連接的請求，因此只要修改c3p0連接池最大最小連接數為。c3p0可以設置如下：  
&lt;property name="hibernate.c3p0.min\_size"&gt;5&lt;/property&gt; &lt;property name="hibernate.c3p0.max\_size"&gt;10&lt;/property&gt;

\--------------------------------------------------------------------------------

問題來了，在系統上線前就要估算有多少用戶會使用這個DB，而每個用戶會使用多少connection，總和不能超過Oracle配置的連線數(看該DB獲得Oracle多少授權connection數)，看來Project的Architecture也得注意這一塊  
ITPUB上的一则讨论 ： [http://www.itpub.net/thread-624935-1-1.html](http://www.itpub.net/thread-624935-1-1.html)

[oravis@ebs](mailto:oravis@ebs) oravis]$ sqlplus

SQL\*Plus: Release 9.2.0.3.0 - Production on Mon Sep 4 14:47:00 2006

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

Enter user-name: sys as sysdba  
Enter password:

Connected to:  
Oracle9i Enterprise Edition Release 9.2.0.3.0 - Production  
With the Partitioning, OLAP and Oracle Data Mining options  
JServer Release 9.2.0.3.0 - Production

SQL&gt; select status from v$instance;

STATUS  
\------------  
OPEN