Posts

Showing posts from March, 2012

Tutorial on Connecting Java application to IBM DB2 Express-C edition (Windows)

Software Prerequisites ·           IBM DB2 Express-C ·           Java SE JDK To begin, we will need to write a Java App. An example is provided below, this app simply shows how to list all the lastname from Employee  table in Java app import java.sql.*; public class testing{  public static void main(String args[])  {        try       {              Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");              Connection con=DriverManager. getConnection("jdbc:db2: sample");              Statement stmt = con.createStatement();              ResultSet resultSet=stmt.executeQuery(" SELECT Lastname from Employee");              System.out.println("Got Results!");              while(resultSet.next()){                      String data=resultSet.getString(" Lastname");                      System.out.println(data);              }              stmt.close();       }              catch(Exception a){              System.out.println(a. g