4

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);
aeycee
  • 167
  • 2
  • 2
  • 14
  • What exception do you get? Are you connecting to an IBM i? Have you started the hosts servers on the IBM i? – jweberhard Feb 10 '15 at 00:20
  • i keep getting the java.net.ConnectException: Connection refused: connect. I have a db2 database installed in my pc. I have successfully connected to my db2 using the db2jcc.jar but now I want to try to connect to my db2 using the jt400.jar. – aeycee Feb 10 '15 at 03:08
  • 2
    jt400.jar can only connect to DB2 on IBM i (aka AS/400). It does not connect to DB2 for windows, unix, linux, or z. – jweberhard Feb 11 '15 at 12:31
  • thanks for the information. I was hoping it would work. – aeycee Feb 13 '15 at 02:03

2 Answers2

8

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"

YLombardi
  • 1,755
  • 5
  • 24
  • 45
0

I know I am late to this party but just wanted to point out a tutorial that might aid others when using Spring Framework and connecting to a DB2 dataSource. In my example, I was using Tomcat Server but it should be applicable to other web servers as well. Anyways, I hope this helps: https://avaldes.com/spring-mvc-with-jndi-datasource-for-db2-on-as400-using-tomcat/