1

We have 13 application servers out of which for one application server when we are starting tomcat we are getting the

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.

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. and we are getting the same error for the java code also.

Things we did to check connectivity:

  1. Telnet is working to the Oracle database server
  2. Network team analysed the tcpdump and there is a successfull handshake between the app and database server

Java Code:

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
Oracle Db version: oracle 11g

James Z
  • 12,209
  • 10
  • 24
  • 44
kkamal
  • 11
  • 1
  • 1
  • 2
  • Sounds like a network / firewall issue, but I'd test it also with sqlplus or some other oracle client just to be sure that the problem is not in the code. – James Z Jul 11 '18 at 16:44
  • we tried sqlplus also it is dislaying the oracle welcome message and after that it is neither going to sql prompt nor it is coming out. it just hangs there with welcome message but when we see the session browser in toad we see a session from that server but it is in inactive. – kkamal Jul 12 '18 at 06:54
  • It`s a common problem, solution exlaned here https://stackoverflow.com/questions/6110395/sqlrecoverableexception-i-o-exception-connection-reset/49775784#49775784 – hatesms Oct 16 '18 at 18:55

1 Answers1

0

We faced a similar issue, on Oracle 11g and Red Hat Linux boxes. The solution was to add these conf/run-time parameters.

-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. For this it uses java to access /dev/random. /dev/random is run by the system and requires hardware interactions like mouse clicks and other keyboard interactions. You may add the parameter as is (note that /./urandom is not a typo).

GopherGopher
  • 376
  • 1
  • 2
  • 16