开发者社区> 问答> 正文

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

@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

 

展开
收起
爱吃鱼的程序员 2020-06-22 13:06:34 1240 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    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)

    哦在生产机上不是一样的是在一台机器上部署的数据库,没有备份数据库所以就一样的

    看看你的驱动是不是支持集群

    http://wenku.baidu.com/link?url=4nW-6bhGGvLcrND_vZSa0noFdR_nt4wKP8RfSw-wpSyYkE52tVqvBq2YIk8VPZq7Ml2SQxLSTDHpgOhI9dlRsU-fwd-8WpvfRakbOzgRCoG

    支持的用的是ojdbc6.jar帮帮忙啊

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

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

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

    比如是否设置: FastConnectionFailoverEnabled=true。

    是否正确配置ONS。

    classpath下是否有ons.jar

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

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

    你查查是不是有其它应用连着数据库,导致数据库session数满了,如果是可以调大Oracle的session数Oracle用的什么版本

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

    Oracle用的什么版本
    2020-06-22 13:06:53
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
阿里云分析引擎Spark On 多数据源介绍 立即下载
低代码开发师(初级)实战教程 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载

相关实验场景

更多