0

We are using Java applications with JDBC/JTOpen to AS400/IBM i DB2. Currently using JTOpen v.10.5 which works fine. Trying to upgrade to latest v.10.7 but it fails with:

java.sql.SQLException: No suitable driver found for jdbc:as400://myserver.domain.net/MYDB;
    at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:706)
    at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:229)
    at TestMain.main(TestMain.java:14)

Same goes for v.10.6

Using a very simple test client:


import java.sql.*;

public class TestMain {
   static final String DB_URL = "jdbc:as400://myserver.domain.net/MYDB;";
   static final String USER = "myuser";
   static final String PASS = "mypasswd";
   static final String QUERY = "select * from MYTABLE";

   public static void main(String[] args) {
     try(Connection conn = DriverManager.getConnection(DB_URL, USER, PASS);
         Statement stmt = conn.createStatement();
         ResultSet rs = stmt.executeQuery(QUERY);) {
         while (rs.next()) {
            System.out.print("IRAVTNR: " + rs.getString("IRAVTNR"));
            System.out.println(", IRISUF: " + rs.getInt("IRISUF"));
         }
      } catch (SQLException e) {
         e.printStackTrace();
      } 
   }
}

I cannot see anything relevant in the changelog. Do you have any idea what is failing?

4integration
  • 193
  • 1
  • 3
  • 13
  • Strange I use the last version without any problem. Are you sure jt400.jar is on the class path? And did you select the right version of jt400.jar for your Java version? – Dam Apr 07 '22 at 10:42
  • 1
    What happens if you explicitly try to load the driver class with `Class.forName`? Does it throw an exception, if so, what is the exception stacktrace? – Mark Rotteveel Apr 07 '22 at 10:55
  • When adding `Class.forName("com.ibm.as400.access.AS400JDBCDriver");` it works. This is however a test app but in reality we are using Kafka Connect with Java 17. Cannot run `Class.forName...` in Kafka Connect Using the jt400.jar from the root of `libs` – 4integration Apr 07 '22 at 13:06

1 Answers1

0

Even though we are using Java 17, I tested with the one in java8/jt400.jar and that works fine. The main jar in root works if you add Class.forName...

Jar file          Contents
--------          --------
jt400.jar(*)         This is the main JTOpen jar file. It contains almost all open
                     source code (except for the few Toolbox classes that could
                     not be open-sourced), including the utilities package,
                     and the JDBC driver (JDBC 3.0).

java8/jt400.jar(*)   This is the main JTOpen jar file compiled for Java 8. 
                     A Java 8 JVM is required to use this class. 
4integration
  • 193
  • 1
  • 3
  • 13