Establish connection to db2 using the jt400.jar

aeycee picture aeycee · Feb 9, 2015 · Viewed 21.1k times · Source

I have tried using the db2jcc.jar and I successfully establish connection to db2 but now I am trying to use the jt400.jar

I have tried to use the driver com.ibm.db2.jdbc.app.DB2Driver but I keep getting the class not found exception.

I tried using the com.ibm.as400.access.AS400JDBCDriver but I can't establish connection.

Can anyone help me or provide a sample code with the connection string connecting to a db2 with jt400.jar.

Class.forName("com.ibm.as400.access.AS400JDBCDriver");
Properties prop = new Properties();

prop.setProperty("user", "current");
prop.setProperty("password", "current");

con = DriverManager.getConnection("jdbc:as400://server/database", prop);

Answer

YLombardi picture YLombardi · Mar 31, 2015

I use this code to connect to my db2 database with jt400 :

Class.forName("com.ibm.as400.access.AS400JDBCDriver");
        connection = DriverManager.getConnection(
                "jdbc:as400:" + iseries + ";database name=" + iasp + ";prompt=false;translate binary=true;naming=system", login, password);

For exemple, if I try to connect to the server "server1" and the database "database1", the url is "jdbc:as400:server1;database name=database1;prompt=false;translate binary=true;naming=system"