oracle(rac)+druid 连接异常,connect reset

各位好!最近在线上遇到一个问题,重启应用服务后第一次访问以及闲置一段时间都会出现下面的错误,已经排除了防火墙、驱动包,且加上druid提供的testOnBorrow也不能解决第一次的问题!
[DruidDataSource.java:1111] discard connection
java.sql.SQLRecoverableException: IO 错误: Connection reset
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1067)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1207)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1296)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3613)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3657)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1495)
at com.alibaba.druid.pool.DruidPooledPreparedStatement.executeQuery(DruidPooledPreparedStatement.java:227)
at org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:646)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:589)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:639)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:668)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:676)
at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:731)
at com.csii.ccbs.aplt.tran.ThreadTranArea.queryForObject(ThreadTranArea.java:937)
at com.csii.ccbs.aplt.TranContext.queryForObject(TranContext.java:1135)
at com.csii.ccbs.aplt.service.trs.impl.CtranctServiceImpl.getTranControl(CtranctServiceImpl.java:66)
at com.csii.ccbs.aplt.tran.ThreadTranArea.getCtranct(ThreadTranArea.java:579)
at com.csii.ccbs.aplt.TranContext.getCtranct(TranContext.java:718)
at com.csii.ccbs.aplt.oltp.base.template.CcbsTranTemplate.execute(CcbsTranTemplate.java:110)
at com.csii.pe.chain.command.DelegateCommand.execute(DelegateCommand.java:39)
at com.csii.pe.chain.ChainImpl.execute(ChainImpl.java:114)
at com.csii.pe.core.CoreControllerImpl.execute(CoreControllerImpl.java:113)
at com.csii.ccbs.aplt.monitor.MoniteredCoreController.execute(MoniteredCoreController.java:195)
at com.csii.pe.channel.stream.AbstractBaseHandler.handleInternal(AbstractBaseHandler.java:211)
at com.csii.pe.channel.stream.AbstractBaseHandler.handle(AbstractBaseHandler.java:107)
at com.csii.pe.service.comm.tcp.TcpServer.internalHandle(TcpServer.java:281)
at com.csii.pe.service.comm.tcp.TcpServer.access$7(TcpServer.java:263)
at com.csii.pe.service.comm.tcp.TcpServer$3.run(TcpServer.java:256)
at com.csii.pe.service.executor.PooledExecutor$InnerRunnable.run(PooledExecutor.java:227)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:196)
at java.net.SocketInputStream.read(SocketInputStream.java:122)
at oracle.net.ns.Packet.receive(Packet.java:308)
at oracle.net.ns.DataPacket.receive(DataPacket.java:106)
at oracle.net.ns.NetInputStream.getNextPacket(NetInputStream.java:324)
at oracle.net.ns.NetInputStream.read(NetInputStream.java:268)
at oracle.net.ns.NetInputStream.read(NetInputStream.java:190)
at oracle.net.ns.NetInputStream.read(NetInputStream.java:107)
at oracle.jdbc.driver.T4CSocketInputStreamWrapper.readNextPacket(T4CSocketInputStreamWrapper.java:124)
at oracle.jdbc.driver.T4CSocketInputStreamWrapper.read(T4CSocketInputStreamWrapper.java:80)
at oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:1137)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:350)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:227)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:208)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1046)
... 31 common frames omitted

2个回答

我也遇到同样的问题,我是这样解决的,
首先出现这样的问题原因是在一定的时候内没有获取到数据库连接,超时所导致的。
在tomcat 下的 catalina.sh
第一行添加 JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom"
你可以试一试。

这个帖子应该可以解决你的问题:

https://blog.csdn.net/xichenguan/article/details/78916467

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐