Java JDBC connectedness to DB2 AS400 database example

To brand a connectedness to DB2 on AS400 using JDBC nosotros quest the next values

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

Instead of putting the values correct into the plan its improve to soft code them using a properties file.

Sample properties file for JDBC connectedness

#I-series ip or host mention local_system=XXX.XXX.XXX.XXX  #I-series UserId, used for login together with library listing userId=XXXXXXX   #I-series Password password=XXXXXXX 

Sample coffee plan for JDBC connection

static Properties props;  endeavour {   props = novel 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   Class.forName(DRIVER);   conn = DriverManager.getConnection(URL, props.getProperty("userId").trim(), props.getProperty("password").trim());    conn.close();  } grab (Exception e) {  System.out.println(e); } 

You quest the jt400.jar inwards your classpath for the project. You tin extract a re-create from the iSeries IFS directory.

Hosting Unlimited Indonesia