java.sql.SQLRecoverableException:Io 异常: Connection reset

1.场景问题

场景:项目启动阶段初始化数据库连接池
## Oracle数据库
## 服务端连接数1500
## 项目maxActive=20
## 服务端连接43
## 说明:启动一直报错,但是项目是可以启动起来的

 2.分析问题

错误一:
 ## 连接ORACLE服务器,客户端要生成随机密钥用于客户端认证,JDK默认使用/dev/random,random采用阻塞方式生成随机数,生成的速度很慢,ORACLE服务器会主动reset,然后报错。

错误二:
##  其实差不多,是因为算法速度的问题导致的

3.解决方案

一:修改jdk目录下文件配置
> vim $JAVA_HOME/jre/lib/security/java.security
## 将securerandom.source=file:/dev/random 改为file:/dev/urandom(urandom采用非阴塞式生成随机数,性能很好,不会产生超时)

- 其实在查看发现默认的就是:file:/dev/urandom

- 认为可能没有使用此处的文件,或不是这么使用的

二:JVM参数方式
> vim  项目启动脚本.sh
> vim JAVA_OPTIONS = "-Djava.security.egd=file:/dev/./urandom"

 4.JDK源码分析

if (egdSource.equals(URL_DEV_RANDOM) || egdSource.equals(URL_DEV_URANDOM)){  
            try {  
                instance = new NativeSeedGenerator();  
                if (debug != null) {  
                  debug.println("the instance:"+instance.getClass());  
                    debug.println("Using operating system seed generator");  
                }  
            } catch (IOException e) {  
                if (debug != null) {  
                    debug.println("Failed to use operating system seed "  
                                  + "generator: "+ e.toString());  
                }  
            }  
        }  
else if (egdSource.length() != 0) {  
            try {  
                instance = new URLSeedGenerator(egdSource);  
                if (debug != null) {  
                    debug.println("Using URL seed generator reading from "  
                                  + egdSource);  
                }  
            } catch (IOException e) {  
                if (debug != null)  
                    debug.println("Failed to create seed generator with "  
                                  + egdSource + ": " + e.toString());  
            }  
        }  

 参考链接:https://blog.csdn.net/raintungli/article/details/42876073

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值