Home » Java » oracle – IO Error: The Network Adapter could not establish the connection Cause (Caused by: java.net.BindException: Address already in use: connect)-Exceptionshub

oracle – IO Error: The Network Adapter could not establish the connection Cause (Caused by: java.net.BindException: Address already in use: connect)-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment

Questions:

We have experienced database connection issues in our application. After restarting it resolves the issue .But what can be the cause. here is the complete stack trace,

2020-02-18 06:02:35,236 [Thread-0] ERROR DbConnection : Db error
java.sql.SQLRecoverableException: IO Error: The Network Adapter could not establish the connection
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:743)
    at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:666)
    at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:566)
    at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:677)
    at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:228)
    at utils.DbConnection.getConnection(DbConnection.java:25)
    at  clientapplication.RequestAndResponseHistory.insertRequestAndResponseIntoDb(RequestAndResponseHistory.java:51)
    at clientapplication.RequestAndResponseHistory.run(RequestAndResponseHistory.java:34)
Caused by: oracle.net.ns.NetException: The Network Adapter could not establish the connection
    at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:470)
    at oracle.net.resolver.AddrResolution.resolveAndExecute(AddrResolution.java:506)
    at oracle.net.ns.NSProtocol.establishConnection(NSProtocol.java:595)
    at oracle.net.ns.NSProtocolStream.negotiateConnection(NSProtocolStream.java:220)
    at oracle.net.ns.NSProtocol.connect(NSProtocol.java:264)
    at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1452)
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:496)
    ... 8 more
Caused by: java.net.BindException: Address already in use: connect
    at java.base/java.net.PlainSocketImpl.waitForConnect(Native Method)
    at java.base/java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:107)
    at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399)
    at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242)
    at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224)
    at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:403)
    at java.base/java.net.Socket.connect(Socket.java:591)
    at oracle.net.nt.TcpNTAdapter.connect(TcpNTAdapter.java:161)
    at oracle.net.nt.ConnOption.connect(ConnOption.java:159)
    at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:428)
    ... 14 more

But during that time ,we can able to establish connection with the database using Sql developer.

What can be the issue here? How we can avoid it?

Here is the connection string,

jdbc:oracle:thin:@SERVERNAME:1521/test JDBC : https://mvnrepository.com/artifact/com.oracle/ojdbc7/12.1.0.2

How to&Answers: