ERRORCODE=-4499, SQLSTATE=08001 – JDBC Error resolution

Connection reset. ERRORCODE=-4499 A communication error occurred during operations on the connection's underlying socket, socket input stream, or socket output stream. Error location: Reply.fill() - socketInputStream.read (-1). Message: Connection reset. ERRORCODE=-4499, SQLSTATE=08001

If you try to solve this problem of connection with JDBC to your DB2 database for example here are some keys which will allow you to quickly correct this problem.

Introduction – ERRORCODE=-4499, SQLSTATE=08001 – JDBC Error resolution

JDBC (Java Database Connectivity) is a programming interface for Java programs. It is a driver that allows Java applications to access databases through a common interface.

Make a test program for JDBC connection :

Starting from this example: Website github.com. I managed to create a sample program that connects to JDBC to help troubleshoot errors :

public class JCCTester
{
  public static void main (String[] args) throws Exception
  {

      String ServerName = "YOURSERVERNAME"
      int PortNumber = 55555
      String DatabaseName = "MYDATABSE"
      String userid = "MYUSERID"
      String password = "MYPASSWD"

      String url = "jdbc:db2://" + ServerName + ":"+ PortNumber + "/" +  DatabaseName;

      java.util.Properties properties = new java.util.Properties();
      properties.put("user", userid);
      properties.put("password", password);


      java.sql.Connection con = null;
      try
      {
          Class.forName("com.ibm.db2.jcc.DB2Driver").newInstance();
      }
      catch ( Exception e )
      {
          System.out.println("Error: failed to load Db2 jcc driver.");
      }

      try
      {
          con = java.sql.DriverManager.getConnection(url, properties);
          System.out.println("Connected through JCC Driver");

      }
      catch (Exception e)
      {
         System.out.println("Error occurred in getting Connection: "+ e.getMessage());
      }
  }
}

To be able to run it you need to download the dependency from Website www.ibm.com

For the version 4 : db2jcc4.jar

For the version 3 : db2jcc.jar

You need to add it in the CLASSPATH (if you are using eclipse this can be done by right click Properties, also with MAVEN you can find the dependency to add in your pom.xml see : Website mvnrepository.com)

<!-- https://mvnrepository.com/artifact/com.ibm.db2.jcc/db2jcc -->
<dependency>
    <groupId>com.ibm.db2.jcc</groupId>
    <artifactId>db2jcc</artifactId>
    <version>db2jcc4</version>
</dependency>

Error resolution – Error location: Reply.fill() - socketInputStream.read (-1)

In general to resolve this type of error you should check if the connection to the database does not require a connection secured by SSL in this case :

Name: sslConnection Value: true
Name: sslTrustStoreLocation Value:
Name: sslTrustStorePassword Value:

It means that your URL become JDBC:db2://{host}{:port}}/{database}:sslConnection=true;sslTrustStoreLocation=/location/to/your/cacerts;sslTrustStorePassword=passwd;

To make a try you can relaunch the test program with the line

  String url = "jdbc:db2://" + ServerName + ":"+ PortNumber + "/" +  DatabaseName + ":sslConnection=true;sslTrustStoreLocation=/location/to/your/cacerts;sslTrustStorePassword=passwd;";

public class JCCTester
{
  public static void main (String[] args) throws Exception
  {

      String ServerName = "YOURSERVERNAME"
      int PortNumber = 55555
      String DatabaseName = "MYDATABSE"
      String userid = "MYUSERID"
      String password = "MYPASSWD"

      String url = "jdbc:db2://" + ServerName + ":"+ PortNumber + "/" +  DatabaseName + ":sslConnection=true;sslTrustStoreLocation=/location/to/your/cacerts;sslTrustStorePassword=passwd;";

      java.util.Properties properties = new java.util.Properties();
      properties.put("user", userid);
      properties.put("password", password);


      java.sql.Connection con = null;
      try
      {
          Class.forName("com.ibm.db2.jcc.DB2Driver").newInstance();
      }
      catch ( Exception e )
      {
          System.out.println("Error: failed to load Db2 jcc driver.");
      }

      try
      {
          con = java.sql.DriverManager.getConnection(url, properties);
          System.out.println("Connected through JCC Driver");

      }
      catch (Exception e)
      {
         System.out.println("Error occurred in getting Connection: "+ e.getMessage());
      }
  }
}

Internal link :

https://128mots.com/index.php/2021/01/31/installer-kubernetes-mac/

External link – Connection reset. ERRORCODE=-4499 :

Website www.oracle.com