Hi All,

I have started development in servlets recently.  Facing problem while
establishing connection with Access & SQL databases using JDBC driver.

my Classpath:
CLASSPATH=.;c:\jsdk2.1\servlet.jar

My code:
public class dbtest {
 public static void main() throws SQLException {

  Class.forName("jdbc.odbc.JdbcOdbcDriver");
  Connection con = DriverManager.getConnection("jdbc:odbc:helpline.dsn", "",
"");

  Statement stmt = con.createStatement();
  ResultSet rs = stmt.executeQuery ("SELECT * FROM cities");

  while (rs.next())
    {
      out.println(rs.getString("pin"));
    }
 }
};

The error:
D:\mobile\scripts>javac dbtest.java
dbtest.java:2: Class SQLException not found in throws.
        public static void main() throws SQLException {
                                         ^
dbtest.java:4: Exception java.lang.ClassNotFoundException must be caught, or
it must be declared in the throws claus
e of this method.
                Class.forName("jdbc.odbc.JdbcOdbcDriver");
                             ^
dbtest.java:5: Class Connection not found.
                Connection con =
DriverManager.getConnection("jdbc:odbc:helpline.dsn", "", "");
                ^
dbtest.java:5: Undefined variable or class name: DriverManager
                Connection con =
DriverManager.getConnection("jdbc:odbc:helpline.dsn", "", "");
                                 ^
dbtest.java:7: Class Statement not found.
                Statement stmt = con.createStatement();
                ^
dbtest.java:8: Class ResultSet not found.
                ResultSet rs = stmt.executeQuery ("SELECT * FROM cities");
                ^
dbtest.java:12: Undefined variable or class name: out
                    out.println(rs.getString("pin"));
                    ^
7 errors


What might be wrong?  Do I need to add anything to my CLASSPATH?

Thanx & Regards,

Kaushal.

___________________________________________________________________________
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