ankit7 0 Newbie Poster

hiii,
i hav made a servlet and connect it to database through oracle.
But while running it i m encountering this error "Couldn't load database driver: oracle.jdbc.driver.OracleDriver".
Please help me as i unable to proceed further in my project.
my servlet is like this::

/*
 * facregistrationform.java
 *
 * Created on May 5, 2009, 11:44 AM
 */

package com.mycompany.servlet;

import java.io.*;
import java.net.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.Connection;

/**
 *
 * @author ANKIT
 * @version
 */
public class facregistrationform extends HttpServlet {
    public void init(ServletConfig config) throws ServletException{
        super.init(config);
    }
    /** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
     * @param request servlet request
     * @param response servlet response
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        /* TODO output your pag
         e here
        out.println("<html>");
        out.println("<head>");
        out.println("<title>Servlet facregistrationform</title>");
        out.println("</head>");
        out.println("<body>");
        out.println("<h1>Servlet facregistrationform at " + request.getContextPath () + "</h1>");
        out.println("</body>");
        out.println("</html>");
         */
        out.close();
    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /** Handles the HTTP <code>GET</code> method.
     * @param request servlet request
     * @param response servlet response
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    }
    
    /** Handles the HTTP <code>POST</code> method.
     * @param request servlet request
     * @param response servlet response
     */
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        
        String connectionURL ="jdbc:odbc:thin:@localhost:8084/ORACLE";
        Connection connection=null;
    ResultSet rs;
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    //get the variables entered in the form
    String contactno = request.getParameter("contactno");
    String name = request.getParameter("name");
    String stream = request.getParameter("stream");
    String salary = request.getParameter("salary");
    String email = request.getParameter("email");
    String address = request.getParameter("address");
    String date = request.getParameter("dd");
    String qualification = request.getParameter("qualification");
    String gender = request.getParameter("gender");
   try { 
      // Load the database driver
      Class.forName("oracle.jdbc.driver.OracleDriver");
      // Get a Connection to the database
      connection = DriverManager.getConnection(connectionURL, "scott", "tiger"); 
      //Add the data into the database
      String sql = "insert into facregistrationform values (?,?,?,?,?,?,?,?,? )";
      PreparedStatement pst = connection.prepareStatement(sql);
      pst.setString(1, contactno);
      pst.setString(2, name);
      pst.setString(3, stream);
      pst.setString(4, salary);
      pst.setString(5, email);
      pst.setString(6, address);
      pst.setString(7, date);
      pst.setString(8, qualification);
      pst.setString(8, gender);

      int numRowsChanged = pst.executeUpdate();
      // show that the new account has been created
      out.println(" Hello : ");
      out.println(" '"+name+"'");
      pst.close();
    }
    catch(ClassNotFoundException e){
      out.println("Couldn't load database driver: " + e.getMessage());
    }
    catch(SQLException e){
      out.println("SQLException caught: " + e.getMessage());
    }
    catch (Exception e){
      out.println(e);
    }
    finally {
      // Always close the database connection.
      try {
        if (connection != null) connection.close();
      }
      catch (SQLException ignored){
        out.println(ignored);
      }
    }
  }

}
    
    /** Returns a short description of the servlet.
     */
   
    // </editor-fold>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.