zoukankan      html  css  js  c++  java
  • SQLRecoverableException: I/O Exception: Connection reset

    https://stackoverflow.com/questions/6110395/sqlrecoverableexception-i-o-exception-connection-reset

    The error occurs on some RedHat distributions. The only thing you need to do is to run your application with parameter java.security.egd=file:///dev/urandom:

    java -Djava.security.egd=file:///dev/urandom [your command]


    11

    I want to produce a complementary answer of nacho-soriano's solution ...

    I recently search to solve a problem where a Java written application (a Talend ELT job in fact) want to connect to an Oracle database (11g and over) then randomly fail. OS is both RedHat Enterprise and CentOS. Job run very quily in time (no more than half a minute) and occur very often (approximately one run each 5 minutes).

    Some times, during night-time as work-time, during database intensive-work usage as lazy work usage, in just a word randomly, connection fail with this message:

    Exception in component tOracleConnection_1
    java.sql.SQLRecoverableException: Io exception: Connection reset
            at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:101)
            at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:112)
            at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:173)
            at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:229)
            at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:458)
            at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:411)
            at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:490)
            at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:202)
            at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:33)
            at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:465)
            at java.sql.DriverManager.getConnection(DriverManager.java:664)
            at java.sql.DriverManager.getConnection(DriverManager.java:208)
        and StackTrace follow ...

    Problem explanation:

    As detailed here

    Oracle connection needs some random numbers to assume a good level of security. Linux random number generator produce some numbers bases keyboard and mouse activity (among others) and place them in a stack. You will grant me, on a server, there is not a big amount of such activity. So it can occur that softwares use more random number than generator can produce.

    When the pool is empty, reads from /dev/random will block until additional environmental noise is gathered. And Oracle connection fall in timeout (60 seconds by default).

    Solution 1 - Specific for one app solution

    The solution is to give add two parameters given to the JVM while starting:

    -Djava.security.egd=file:/dev/./urandom
    -Dsecurerandom.source=file:/dev/./urandom

    Note: the '/./' is important, do not drop it !

    So the launch command line could be:

    java -Djava.security.egd=file:/dev/./urandom -Dsecurerandom.source=file:/dev/./urandom -cp <classpath directives> appMainClass <app options and parameters>

    One drawback of this solution is that numbers generated are a little less secure as randomness is impacted. If you don't work in a military or secret related industry this solution can be your.

    https://blog.csdn.net/jackie_xiaonan/article/details/37740359

    从Oracle官网论坛里找到一个帖子,讨论的问题和我遇到的问题类似,但提出的问题原因和解决方法比较有意思。按照帖子里的说法,问题的根因和Java的安全随机数生成器的实现原理相关


    随机数生成器

    如果不是为了解决问题,平时也不会去刻意查阅底层实现相关的原理,这次是个好机会。网上关于/dev/random的介绍很多,只列出要点:

    1) /dev/random是Linux内核提供的安全随机数生成设备;

    2) /dev/random依赖系统中断信息来生成随机数,因而设备数目比较少时,产生随机数的速度比较慢,当应用对随机数的需求比较大时会供不应求;

    3) /dev/random在读取时会阻塞调用线程;

    4) /dev/urandom是/dev/random的改良版本,解决了随机数生成慢、阻塞调用的问题,但同时稍微降低了安全性;

    5) Linux环境下man random命令可以查阅到/dev/random和/dev/urandom的介绍,比较详尽; 

  • 相关阅读:
    cordova 里js和oc通信原理
    awakeFromNib
    CALayer树形结构
    SDWebImage原理,转载
    gcd多线程
    block的存储形态
    关于weak对象什么时候释放
    Swift是否和OC一样有runtime机制
    大数据基础
    python进行离线打包并安装
  • 原文地址:https://www.cnblogs.com/kakaisgood/p/11389776.html
Copyright © 2011-2022 走看看