简体   繁体   中英

IO Error: Socket read timed out. What are the reasons?

My simplified code (which demonstrates that the connection breaks with error "IO Error: Socket read timed out"):

    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    this.connection = DriverManager.getConnection("jdbc:oracle:thin:@", properties);
    while(isStarted){
        this.statement = this.connection.createStatement();
        ResultSet result = this.statement.executeQuery("select sysdate from dual");
        result.next();
        System.out.println("Sysdate: " + result.getString(1));
        result.close();
        this.statement.close();
        this.statement = null;
        TimeUnit.SECONDS.sleep(4);
    }
    this.connection.close();
    this.connection = null;

after 4-5 hours i catched:

 IO Error: Socket read timed out
    java.sql.SQLRecoverableException: IO Error: Socket read timed out
at oracle.jdbc.driver.T4CStatement.executeForDescribe(T4CStatement.java:886)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1167)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1289)
at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:1491)
at oracle.jdbc.driver.OracleStatementWrapper.executeQuery(OracleStatementWrapper.java:406)

What are the reasons? how to solve this problem?

I had the same problem. Check your services and see to it that only OracleServiceXE and Oracle XETNSListener is running.

You can crosscheck it in cmd by using command

netstat -ano | find "1521"

In the result the last column shows the PID and it should be unique. If the command returns no result then your Listener is not running.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM