You are on page 1of 1

DB2 JDBC Steps: 1. Add db2jcc.jar, db2jcc_license_cu.

jar to your classpath: > Right click on project > Properties > Java Build Path > Libraries > Add External JARs > Browse to the location where you have kept above two jars. Default location is "C:\Program Files (x86)\IBM\SQLLIB\java" for Windows 7 OS 2. Create a plane java class and add following code: Class.forName("com.ibm.db2.jcc.DB2Driver"); Connection con=DriverManager.getConnection("jdbc:db2://localhost:50000/MYDB:retrieveMessagesFromServer OnGetMessage=true;","db2Admin","a"); //MYDB is the name of the target database Statement st=con.createStatement(); String sql="insert into MYSCHEMA.STUD values('value1','value2','value3')"; st.executeUpdate(sql); System.out.println("Success!"); 3. For Eclipse users, you may need to copy the above jars under lib folder(under Web content> WEB-INF) of your project directory.

You might also like