Your code is right. Please recheck the CLASSPATH to DB2 drivers. Normally
this error will appear due to improper CLASSPATH.

Good Luck...

~Hemadri Naidu

___________________________________________
Hemadri Gurramkonda            DigitalRiver




-----Original Message-----
From: Madumathi k [mailto:[EMAIL PROTECTED]]
Sent: Monday, September 27, 1999 2:14 AM
To: [EMAIL PROTECTED]
Subject: connecting to db2


can anyone help me in the following code :
(Error while connecting to db2)


$ java DB2Appl
class for name

get Connection error

java.sql.SQLException: No suitable driver
        at java.lang.Throwable.<init>(Compiled Code)
        at java.lang.Exception.<init>(Compiled Code)
        at java.sql.SQLException.<init>(Compiled Code)
        at java.sql.DriverManager.getConnection(Compiled Code)
        at java.sql.DriverManager.getConnection(Compiled Code)
        at DB2Appl.main(Compiled Code)


The following is the source code :
import java.net.URL;
import java.sql.*;
import ibm.sql.*;

class DB2Appl {

   static {
      try {
         // register the driver with DriverManager
         Class.forName("ibm.sql.DB2Driver");
         //DriverManager.registerDriver(new DB2Driver());
        System.out.println ("class for name\n");
      } catch (ClassNotFoundException e) {
        System.out.println(" for name error \n");
         e.printStackTrace();

      }
   }

   public static void main(String argv[]) {
      try {
         // URL is jdbc:db2:dbname
         String url = "jdbc:db2:sample";
         Connection con = DriverManager.getConnection(url);
         // retrieve data from the database
         System.out.println("Retrieve some data from the database...");
        con.close();
      } catch( Exception e ) {
        System.out.println ("get Connection error\n");
         e.printStackTrace();
      }
   }
}



thanks in advance
madumathi

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to