I sincerely apologise again....
Problem solved..
I put System.out.println instead of out.println.
I also put "main(String[] args)" instead of main().
And I put "sun.jdbc.odbc.JdbcOdbcDriver" instead of
jdbc.odbc.JdbcOdbcDriver.
Thanx :-) & Regards,
Kaushal.
----- Original Message -----
From: wap@asl <[EMAIL PROTECTED]>
To: Servlet Forum <[EMAIL PROTECTED]>
Sent: Monday, July 24, 2000 4:54 PM
Subject: Fw: JDBC
> Sorry,
>
> My mistake. I did not include import java.sql.*; line in my code. After
> including it, it gives the error
>
> D:\mobile\scripts\dbtest.java:5: Exception
java.lang.ClassNotFoundException
> must be caught, or it must be declared in the throws clause of this
method.
> Class.forName("jdbc.odbc.JdbcOdbcDriver");
> ^
> D:\mobile\scripts\dbtest.java:13: Undefined variable or class name: out
> out.println(rs.getString("pin"));
> ^
> 2 errors
>
> Process completed with exit code 1
>
> Help,
>
> Thanx & Regards,
>
> Kaushal.
> ----- Original Message -----
> From: wap@asl <[EMAIL PROTECTED]>
> To: Servlet Forum <[EMAIL PROTECTED]>
> Sent: Monday, July 24, 2000 4:45 PM
> Subject: JDBC
>
>
> > 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