java.sql.SQLException: A communications error has been detected: Software caused connection abort: recv failed.

Apache's JIRA Issue Tracker | Kathey Marsden | 10 years ago
tip
Do you find the tips below useful? Click on the to mark them and say thanks to rafael . Or join the community to write better ones.
  1. 0

    [DERBY-3077] Trying to reconnect with derby client after bringing server down throws SQL Exception 58009 rather than 08XXX exception - ASF JIRA

    apache.org | 1 year ago
    java.sql.SQLException: A communications error has been detected: Software caused connection abort: recv failed.
  2. 0

    This issue was discussed in DERBY-401, because the case where the server is brought down and an application tries to reconnect does not throw a SQLNonTransientException. Discussion is still underway about whether 58XXX exceptions should be SQLNonTransientExceptions, but at least for this case changing the exception to 08006 per Knut's suggestion should correct the problem for this case. See https://issues.apache.org/jira/browse/DERBY-401#action_12527400 Below is current stack and test case. Apache Derby got connection now sleep now try to use the connection after you killed the nS Exception in thread "main" java.sql.SQLException: A communications error has been detected: Software caused connection abort: recv failed. at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unknown Source) at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source) at org.apache.derby.client.am.Connection.prepareStatement(Unknown Source) at org.apache.derby.client.am.LogicalConnection.prepareStatement(Unknown Source) at DerbyClientNonXA.main(DerbyClientNonXA.java:48) Caused by: org.apache.derby.client.am.DisconnectException: A communications error has been detected: Software caused connection abort: recv failed. at org.apache.derby.client.net.NetAgent.throwCommunicationsFailure(Unknown Source) at org.apache.derby.client.net.Reply.fill(Unknown Source) at org.apache.derby.client.net.Reply.ensureALayerDataInBuffer(Unknown Source) at org.apache.derby.client.net.Reply.readDssHeader(Unknown Source) at org.apache.derby.client.net.Reply.startSameIdChainParse(Unknown Source) at org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(Unknown Source) at org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(Unknown Source) at org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(Unknown Source) at org.apache.derby.client.am.Statement.readPrepareDescribeOutput(Unknown Source) at org.apache.derby.client.am.PreparedStatement.readPrepareDescribeInputOutput(Unknown Source) at org.apache.derby.client.am.PreparedStatement.flowPrepareDescribeInputOutput(Unknown Source) at org.apache.derby.client.am.PreparedStatement.prepare(Unknown Source) at org.apache.derby.client.am.Connection.prepareStatementX(Unknown Source) ... 3 more Caused by: java.net.SocketException: Software caused connection abort: recv failed at java.net.SocketInputStream.read(SocketInputStream.java:129) ... 15 more import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Statement; import javax.sql.PooledConnection; public class DerbyClientNonXA { public static void main(String args[]) throws Exception { org.apache.derby.jdbc.ClientConnectionPoolDataSource40 ds = new org.apache.derby.jdbc.ClientConnectionPoolDataSource40(); Connection conn = null; ds.setDatabaseName("e:\\temp\\sampl127;create=true"); PooledConnection pooledCon = ds.getPooledConnection(); conn = pooledCon.getConnection(); DatabaseMetaData md = conn.getMetaData(); System.out.println(md.getDatabaseProductVersion()); System.out.println(md.getDatabaseProductName()); System.out.println("got connection now sleep. Bring down network server."); Statement st = null; PreparedStatement ps1 = null; st = conn.createStatement(); try { st.executeUpdate("drop table TAB1"); } catch (SQLException x) { System.out.println("no table exists"); } Thread.sleep(15000); System.out.println("now try to use the connection after you killed the nS"); ps1 = conn.prepareStatement("CREATE TABLE TAB1(COL1 INT NOT NULL)"); ps1.executeUpdate(); conn.commit(); System.out.println("done"); } }

    Apache's JIRA Issue Tracker | 10 years ago | Kathey Marsden
    java.sql.SQLException: A communications error has been detected: Software caused connection abort: recv failed.
  3. 0
    samebug tip
    It's possible you're trying to write to a connection that's already closed. Another cause for this is that you closed the socket with unread data in the socket receive buffer.
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0
    samebug tip
    This might be caused by unmatching versions of SSL. Java starts normally with SSLv2 and your server might not be able to negotiate. You have to force Java to use SSLv3. See this comment: https://goo.gl/hx0YB3
  6. 0

    Strange Exception

    GitHub | 4 years ago | dfarina
    java.net.SocketException: Software caused connection abort: recv failed
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.net.SocketException

    Software caused connection abort: recv failed

    at java.net.SocketInputStream.read()
  2. Java RT
    SocketInputStream.read
    1. java.net.SocketInputStream.read(SocketInputStream.java:129)
    1 frame
  3. Apache Derby Client JDBC Driver
    LogicalConnection.prepareStatement
    1. org.apache.derby.client.net.Reply.fill(Unknown Source)
    2. org.apache.derby.client.net.Reply.ensureALayerDataInBuffer(Unknown Source)
    3. org.apache.derby.client.net.Reply.readDssHeader(Unknown Source)
    4. org.apache.derby.client.net.Reply.startSameIdChainParse(Unknown Source)
    5. org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(Unknown Source)
    6. org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(Unknown Source)
    7. org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(Unknown Source)
    8. org.apache.derby.client.am.Statement.readPrepareDescribeOutput(Unknown Source)
    9. org.apache.derby.client.am.PreparedStatement.readPrepareDescribeInputOutput(Unknown Source)
    10. org.apache.derby.client.am.PreparedStatement.flowPrepareDescribeInputOutput(Unknown Source)
    11. org.apache.derby.client.am.PreparedStatement.prepare(Unknown Source)
    12. org.apache.derby.client.am.Connection.prepareStatementX(Unknown Source)
    13. org.apache.derby.client.am.Connection.prepareStatement(Unknown Source)
    14. org.apache.derby.client.am.LogicalConnection.prepareStatement(Unknown Source)
    14 frames
  4. Unknown
    DerbyClientNonXA.main
    1. DerbyClientNonXA.main(DerbyClientNonXA.java:48)
    1 frame