Blog Archive

Java JDBC connection to DB2 AS400 database example

To make a connection to DB2 on AS400 using JDBC we need the following values

  • Host Name or IP Address of The Machine
  • User Id
  • Password

Instead of putting the values right into the program its better to soft code them using a properties file.

Sample properties file for JDBC connection

#I-series ip or host name

#I-series UserId, used for login and library list

#I-series Password

Sample java program for JDBC connection

static Properties props;

try {

 props = new Properties();
 props.load(new FileInputStream("properties/"));

 String DRIVER = ""; 
 String URL = "jdbc:as400://" + props.getProperty("local_system").trim() + ";naming=system;errors=full";
 Connection conn = null;

 //Connect to iSeries 
 conn = DriverManager.getConnection(URL, props.getProperty("userId").trim(), props.getProperty("password").trim()); 


catch (Exception e) {

You need the jt400.jar in your classpath for the project. You can extract a copy from the iSeries IFS directory.


  1. Hi there colleagues, its fantastic article regarding educationand completely defined,
    keep it up all the time.

  2. Hey there are using WordPress for your site platform?
    I’m new to the blog world but I’m trying to get started and set up
    my own. Do you need any coding expertise to make your own blog?
    Any help would be greatly appreciated!

  3. Your style is really unique in comparison to other folks I have read stuff
    from. Thanks for posting when you’ve got the opportunity, Guess I’ll just bookmark
    this blog.

  4. Hello! This post could not be written any better!

    Reading through this post reminds me of my good old room mate!
    He always kept chatting about this. I will forward this article to him.
    Pretty sure he will have a good read. Many thanks for

  5. Great weblog right here! Additionally your web site rather a lot up fast!
    What web host are you the use of? Can I get your affiliate hyperlink for your host?
    I wish my site loaded up as quickly as yours lol

  6. I visited various websites but the audio quality for audio songs current
    at this site is genuinely marvelous.

  7. it I don't understand, why are all seven things on one single page? As a reader of The Internet I am only capable of comprehending one list item at a time! Jual Boneka Wisuda | Jaket Bomber Pria