you need add to classpath the db2java.zip it is into sqllib directory when you
install db2 in windows NT







Madumathi k <[EMAIL PROTECTED]> on 09/27/99 01:14:20 AM

Please respond to "A mailing list for discussion about Sun Microsystem's Java
Servlet API Technology." <[EMAIL PROTECTED]>



  To:          [EMAIL PROTECTED]

  cc:



  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