简体   繁体   English

如何解决 java.sql.SQLRecoverableException:IO 错误:连接超时

[英]How to resolve java.sql.SQLRecoverableException: IO Error: Connection timed out

We have 13 application servers out of which for one application server when we are starting tomcat we are getting the我们有 13 个应用程序服务器,其中一个应用程序服务器在启动 Tomcat 时得到

SEVERE: Unable to create initial connections of pool.严重:无法创建池的初始连接。 java.sql.SQLRecoverableException: IO Error: Connection timed out.caused by Caused by: java.net.SocketException: Connection timed out. java.sql.SQLRecoverableException:IO 错误:连接超时。原因是:java.net.SocketException:连接超时。

we are not getting the error for the rest of the servers.我们没有收到其余服务器的错误。 so we wrote a java code to test the jdbc to find out whether the error is due to db connectivity or application.所以我们编写了一个java代码来测试jdbc,看看错误是由于db连接还是应用程序引起的。 and we are getting the same error for the java code also.我们也得到了同样的java代码错误。

Things we did to check connectivity:我们为检查连接所做的事情:

  1. Telnet is working to the Oracle database server Telnet 正在访问 Oracle 数据库服务器
  2. Network team analysed the tcpdump and there is a successfull handshake between the app and database server网络团队分析了 tcpdump,应用程序和数据库服务器之间握手成功

Java Code: Java 代码:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class JdbcDemo {
    public static void main(String[] args){
    try{

        Class.forName("oracle.jdbc.driver.OracleDriver");
        System.out.println("COnnection started");
        Connection con = DriverManager.getConnection("jdbc:oracle:thin:@"+"db_ip"+":"+"1521"+"/"+"db_name","db_user","password");
        System.out.println("COnnection Established");
        //Statement st=con.createStatement();
        System.out.println("connection name"+con);
        //ResultSet rs=st.executeQuery("");

    }
    catch(Exception e){

         e.printStackTrace();
    }
}

Error we are getting:我们得到的错误:

root@app_server_ip # java -cp .:ojdbc7.jar JdbcDemo
COnnection started
java.sql.SQLRecoverableException: IO Error: Connection reset
        at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:841)
        at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:755)
        at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:38)
        at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:599)
        at java.sql.DriverManager.getConnection(DriverManager.java:664)
        at java.sql.DriverManager.getConnection(DriverManager.java:247)
        at JdbcDemo.main(JdbcDemo.java:13)
Caused by: java.net.SocketException: Connection reset
        at java.net.SocketInputStream.read(SocketInputStream.java:209)
        at java.net.SocketInputStream.read(SocketInputStream.java:141)
        at oracle.net.ns.Packet.receive(Packet.java:317)
        at oracle.net.ns.DataPacket.receive(DataPacket.java:101)
        at oracle.net.ns.NetInputStream.getNextPacket(NetInputStream.java:301)
        at oracle.net.ns.NetInputStream.read(NetInputStream.java:245)
        at oracle.net.ns.NetInputStream.read(NetInputStream.java:167)
        at oracle.net.ns.NetInputStream.read(NetInputStream.java:85)
        at oracle.jdbc.driver.T4CSocketInputStreamWrapper.readNextPacket(T4CSocketInputStreamWrapper.java:119)
        at oracle.jdbc.driver.T4CSocketInputStreamWrapper.read(T4CSocketInputStreamWrapper.java:75)
        at oracle.jdbc.driver.T4CMAREngineStream.unmarshalUB1(T4CMAREngineStream.java:447)
        at oracle.jdbc.driver.T4C8TTIdty.receive(T4C8TTIdty.java:706)
        at oracle.jdbc.driver.T4C8TTIdty.doRPC(T4C8TTIdty.java:611)
        at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:2161)
        at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:564)
        ... 6 more

App server: Red Hat Enterprise Linux Server release 6.8应用服务器:Red Hat Enterprise Linux Server 6.8 版
Oracle Db version: oracle 11g Oracle Db 版本:oracle 11g

We faced a similar issue, on Oracle 11g and Red Hat Linux boxes.我们在 Oracle 11g 和 Red Hat Linux 机器上遇到了类似的问题。 The solution was to add these conf/run-time parameters.解决方案是添加这些 conf/run-time 参数。

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

The Oracle JDBC driver needs some random numbers to maintain a standard of security. Oracle JDBC 驱动程序需要一些随机数来维持安全标准。 For this it uses java to access /dev/random .为此,它使用 java 来访问/dev/random /dev/random is run by the system and requires hardware interactions like mouse clicks and other keyboard interactions. /dev/random由系统运行,需要硬件交互,如鼠标点击和其他键盘交互。 You may add the parameter as is (note that /./urandom is not a typo).您可以按原样添加参数(注意/./urandom不是错字)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在IntelliJ中收到错误“ java.sql.SQLRecoverableException:IO错误:套接字读取超时” - got error “java.sql.SQLRecoverableException: IO Error: Socket read timed out” in intellij java.sql.SQLRecoverableException:IO错误:生成了NL异常 - java.sql.SQLRecoverableException: IO Error: NL Exception was generated 数据库连接问题 - 引起:java.sql.SQLRecoverableException:IO 错误:指定的主机未知 - Database connection problem - Caused by: java.sql.SQLRecoverableException: IO Error: Unknown host specified java.sql.SQLRecoverableException:错误:Ubuntu中端口号的数字格式无效 - java.sql.SQLRecoverableException: Io error: Invalid number format for port number in ubuntu java.sql.SQLRecoverableException:网络适配器无法建立连接 - java.sql.SQLRecoverableException: The Network Adapter could not establish the connection java.sql.SQLRecoverableException:IO 错误:文件描述符错误,连接失败 1 毫秒,身份验证失败 0 毫秒 - java.sql.SQLRecoverableException: IO Error: Bad file descriptor, connect lapse 1ms, Authentication lapse 0ms java.sql.SQLRecoverableException:控制台/管理员命令已从管理上禁用了连接 - java.sql.SQLRecoverableException: Connection has been administratively disabled by console/admin command java.sql.SQLRecoverableException:使用连接池时是否没有更多数据要从套接字读取? - java.sql.SQLRecoverableException: No more data to read from socket when using a connection pool? 查询oracle多维数据集时出现java.sql.SqlRecoverableException - java.sql.SqlRecoverableException while querying oracle cube java.sql.SQLRecoverableException:没有更多的数据可以从套接字读取 - java.sql.SQLRecoverableException: No more data to read from socket
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM