druid 数据源与纯jdbc相结合,遇到的问题

osLiu 发布于 2014/02/10 11:16
阅读 6K+
收藏 0

@wenshao 你好,想跟你请教个问题:

druid 数据源与纯jdbc相结合,遇到的问题

1、底层是用纯jdbc写的访问oracle数据库

2、将druid数据源与之进行结合时,多次点击页面访问数据库时会出现错误

3、错误信息是:

2014-2-10 10:38:04 com.alibaba.druid.support.logging.JakartaCommonsLoggingImpl info
信息: {dataSource-275} inited
java.sql.SQLException: Listener refused the connection with the following error:
ORA-12516, TNS:listener could not find available handler with matching protocol stack
 
 at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:458)
 at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:546)
 at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:236)
 at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
 at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521)
 at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:146)
 at com.alibaba.druid.filter.stat.StatFilter.connection_connect(StatFilter.java:211)
 at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:140)
 at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1355)
 at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1409)
 at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:602)
 at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:876)
 at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:872)
 at org.gzaic.report.db.DbPoolConnection.getConnection(DbPoolConnection.java:52)
 at org.gzaic.report.db.DBAReport.getConnection(DBAReport.java:73)
 at org.gzaic.report.db.DBAReport.SQLQuery(DBAReport.java:197)
 at org.gzaic.report.dao.impl.CommonDao.queryListByTable(CommonDao.java:50)
 at org.gzaic.report.dao.hr.impl.GwygwflDao.queryList(GwygwflDao.java:28)
 at org.gzaic.report.service.hr.impl.GwygwflService.queryList(GwygwflService.java:32)
 at org.gzaic.report.servlet.hr.ReportGwygwflServlet.list(ReportGwygwflServlet.java:105)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.gzaic.report.comm.BaseSerlvet.doPost(BaseSerlvet.java:82)
 at org.gzaic.report.comm.BaseSerlvet.doGet(BaseSerlvet.java:62)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 at org.gzaic.report.comm.EncondingFilter.doFilter(EncondingFilter.java:49)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
 at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
 at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
 at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
 at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2430)
 at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2419)
 at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
 at java.lang.Thread.run(Thread.java:619)
Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error:
ORA-12516, TNS:listener could not find available handler with matching protocol stack
 
 at oracle.net.ns.NSProtocol.connect(NSProtocol.java:395)
 at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1102)
 at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:320)
 ... 47 more

 

4、但是在不使用druid数据源的情况下是ok的,不管怎么访问数据库都不会报错.您能不能帮我看下这是怎么回事。是因为配置的问题还是数据库方面的问题哈。谢谢

5、jdbc配置:

username=aaaaa
password=aaaaa
url=jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521))(LOAD_BALANCE=yes)(FAILOVER=on))(CONNECT_DATA=(SERVICE_NAME=aaaa)))
driverClassName=oracle.jdbc.driver.OracleDriver

filters=stat
  
maxActive=20
initialSize=1
maxWait=60000
minIdle=10
#maxIdle:15
  
timeBetweenEvictionRunsMillis=60000
minEvictableIdleTimeMillis=300000
  
validationQuery=select 1 from dual
testWhileIdle=true
testOnBorrow=false
testOnReturn=false
#poolPreparedStatements:true
maxOpenPreparedStatements=20
 
#对于长时间不使用的连接强制关闭 
removeAbandoned=true
#超过30分钟开始关闭空闲连接 
removeAbandonedTimeout=1800
#将当前关闭动作记录到日志 
logAbandoned=true

 

加载中
0
猫哥-u
猫哥-u

url=jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521))(LOAD_BALANCE=yes)(FAILOVER=on))(CONNECT_DATA=(SERVICE_NAME=aaaa)))

怎么都是同一个:(HOST=127.0.0.1)(PORT=1521)

osLiu
osLiu
哦 在生产机上不是一样的
osLiu
osLiu
是在一台机器上部署的数据库,没有备份数据库所以就一样的
0
osLiu
osLiu
帮帮忙啊
0
猫哥-u
猫哥-u

测试环境只一台机器就去掉  换成

url=jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=xxxx)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)))(CONNECT_DATA=(SERVICE_NAME=aaaa)))

0
兮风古道
兮风古道

楼主有没有先排除FCF的配置问题呢?

比如是否设置:FastConnectionFailoverEnabled=true。

是否正确配置ONS。

classpath下是否有ons.jar

0
猫哥-u
猫哥-u
问题如何了
osLiu
osLiu
谢谢您的关心不过还是不太ok,依然存在那个错误
0
猫哥-u
猫哥-u
你查查是不是有其它应用连着数据库,导致数据库session数满了,如果是可以调大Oracle的session数
0
osLiu
osLiu

引用来自“猫哥-u”的答案

你查查是不是有其它应用连着数据库,导致数据库session数满了,如果是可以调大Oracle的session数
是这样的早期我也将oracle的session数调过alter system set processes=300 scope=spfile;alter system set sessions=335 scope=spfile;但是后来发现还是不行。数据库连接这块没有其他的应用在连接。我想问下就是druid数据库之前有没有跟这个纯jdbc一块使用过,有没有这方面的案例你知道么?还是说他必须跟一些orm框架才能很好地发挥性能
0
猫哥-u
猫哥-u
Oracle用的什么版本
0
osLiu
osLiu

引用来自“猫哥-u”的答案

Oracle用的什么版本

使用的是Oracle 11g 这个数据库

返回顶部
顶部