You need to import the driver class along with your other classes at the top of your
program.
GL
Moloy Biswas wrote:
> Hi all
>
> I need help very badly. Pl respond.
>
> When I am trying to compile my servlet its giving the following error
>
> Class oracle.jdbc.driver.OracleDriver not found.
>
> its pointing to the following line
>
> DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
> // registering the driver
>
> I am attaching my file with this mail, pl respond
>
> Moloy
>
> ------------------------------------------------------------------------
> import java.io.*;
> import java.sql.*;
> import java.math.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
>
> public class mservlet1 extends HttpServlet
> {
> public void doGet(HttpServletRequest req, HttpServletResponse res)
> throws ServletException, IOException
> {
> Connection con = null;
> Statement stmt = null;
> ResultSet rs = null;
>
> res.setContentType("text/html");
> PrintWriter out = res.getWriter();
>
> try
> {
> //Load and therefore register the driver
> // Class.forName("oracle.jdbc.driver.OracleDriver");
> DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
>
> //Get connection to the database
> con =
>DriverManager.getConnection("jdbc:oracle:oci8:@ORCL","moloy","moloy");
>
> //Create a statement object
> stmt = con.createStatement();
>
> //Execute an SQL query, get a ResultSet
> rs = stmt.executeQuery("SELECT FNAME,LNAME FROM CONTACT");
>
> //Display the result set as a list
> out.println("<HTML><HEAD><TITLE>Moloy's
>list...</TITLE></HEAD>");
> out.println("<BODY><UL>");
> while(rs.next())
> {
> out.println("<LI>" + rs.getString("fname") + " " +
>rs.getString("lname"));
> }
> out.println("</UL>");
> out.println("</BODY></HTML>");
> }
> /* catch (ClassNotFoundException e)
> {
> out.println("Could not load the database driver: " +
>e.getMessage());
> } */
> catch (SQLException e)
> {
> out.println("SQLException caught: " + e.getMessage());
> }
> finally
> {
> //Close all database connection.
> try
> {
> if (con != null)
> con.close();
> }
> catch (SQLException e)
> {
> out.println("SQLException caught: " +
>e.getMessage());
> }
> }
> }
> }
___________________________________________________________________________
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