• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java-DB2

 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,
I've written a simple JDBC program with the intension of connecting to DB2 7.02.I've craeted a table in DB and want my JDBC program shown below to connect it.I'm getting the following error.please help me to sort and understand it better.
code:
import java.util.Hashtable;
import java.util.Properties;

import javax.naming.Context;
import javax.naming.InitialContext;


public class JDBCConnectionFromClient {
static java.sql.Connection con;
/**
* Constructor for JDBCConnectionFromClient.
*/
public JDBCConnectionFromClient() {
super();
}

static {
try {
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
} catch (Exception e) {
System.out.println(e);
}
}

public static void main(String[] args) {
try {
Connection con = DriverManager.getConnection("jdbc b2 RASHDB");
}catch(Exception ex) {
ex.printStackTrace();
}
}
}

Error i got is:
java.lang.ClassNotFoundException: COM.ibm.db2.jdbc.app.DB2Driver
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(DriverManager.java:563)
at java.sql.DriverManager.getConnection(DriverManager.java:216)
at ClientPrograms.JDBCConnectionFromClient.main( JDBCConnectionFromClient.java:43)

Thanks in adavnce
Prashanth
 
Ranch Hand
Posts: 724
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You must have the driver class in your classpath.
this file is db2java.zip and its location on windows is
..\IBM\SQLLIB\java\

put it in your classpath and it should be OK.
 
reply
    Bookmark Topic Watch Topic
  • New Topic