Hi,

I am new to servlets and since one week have been
bogged down with this problem.

I have been reading lots of documentation and since
then modified my classpath etc but still getting
errors.

I want to connect to my oracle database using servlet.

However on running my servlet on the TOMCAT server, I
get the following error:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Error: 500

Location: /hdd/servlet/EmpNo

Internal Servlet Error:

java.lang.IllegalArgumentException:
oracle:jdbc.driver.OracleDriver
        at EmpNo.doGet(Compiled Code)
        at
javax.servlet.http.HttpServlet.service(Compiled Code)
        at
javax.servlet.http.HttpServlet.service(Compiled Code)
        at
org.apache.tomcat.core.ServletWrapper.doService(Compiled
Code)
        at
org.apache.tomcat.core.Handler.service(Compiled Code)
        at
org.apache.tomcat.core.ServletWrapper.service(Compiled
Code)
        at
org.apache.tomcat.core.ContextManager.internalService(Compiled
Code)
        at
org.apache.tomcat.core.ContextManager.service(Compiled
Code)
        at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(Compiled
Code)
        at
org.apache.tomcat.service.TcpWorkerThread.runIt(Compiled
Code)
        at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(Compiled
Code)
        at java.lang.Thread.run(Compiled Code)
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Here is the code that I am using:

import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class EmpNo 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");

  //return early if this is a HEAD request
  if( req.getMethod().equals("HEAD") ) return;

  PrintWriter out = res.getWriter();

  try {

   // Load and therefore register the Oracle Driver
   //Class.forName("oracle:jdbc.driver.OracleDriver");
   DriverManager.registerDriver(new
oracle.jdbc.driver.OracleDriver());

   // Get a connection to the database
   con = DriverManager.getConnection(
                "jdbc:oracle:thin:@server-name:1521:sid",
"scott", "tiger" );

   // Create a statement object
   stmt = con.createStatement();

   // Execute a SQL query and get the result set
   rs = stmt.executeQuery("Select deptno from dept");

   // Display the result set as a combo list
   out.println("<html><head><title>Select the Model of
Disk Drive</title></head>");
   out.println("<div><p>Select the Model Number of the
Disk Drive to display Info.");

   // Display a FORM with the combo box
   out.println("<form action=\"/servlet/ModelNoInfo\"
method=\"get\">");
   out.println("<select name=\"modelno\">");

   while( rs.next() ) {

     out.print("<option>" + rs.getString("modelno") );
     out.println("</option>");

   }//end of while

   out.println("<select></br>");
   out.println("<input type=\"submit\" value=\"
GetInfo \">");
   out.println("</p></form></div>");

   out.println("</body></html>");

  }//end of try
  catch ( ClassNotFoundException e ) {
    out.println( "Couldn't load database Driver: " +
e.getMessage() );
  }
  catch ( SQLException e ) {
    out.println( "SQLException caught: " +
e.getMessage() );
  }
  finally {
    // Always close the database connection.
    try {
      if ( con != null ) {
        con.close();
      }
    }//end of try
    catch (SQLException ignored) { }
  }//end of finally

 }//end of doGet

 public void doPost( HttpServletRequest req,
HttpServletResponse res)
                        throws ServletException, IOException {

   doGet( req, res );

 }

 public String getServletInfo() {

   return "A servlet that returns all the model
numbers available"
      + " in the Deliverables table";
 }//end of getServletInfo

}//end of class

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

I have been trying to see the archives, but didn't
find a solution and I am stuck with my work since I
can't communicate with my database. Please help me!!!!

Thanks in advance,
Ravi Shankar.


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35
a year!  http://personal.mail.yahoo.com/

___________________________________________________________________________
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