Why do you implement the 'service ()' method? According to the HttpServlet
docs:

"You usually will not override the 'service' method. 'service' handles
standard HTTP request by dispatching them to the handler methods for each
HTTP request type (the doXXX methods listed above). "

Try renaming your 'service ()' method to 'doGet ()'.

Arjan Houtman
Antares Informatisering
[EMAIL PROTECTED]


>The source code:
>===============
>import java102.sql.*;
>import java.io.*;
>import javax.servlet.*;
>import javax.servlet.http.*;
>
>
>public class JDBCServlet extends HttpServlet {
>
>   private Connection oracleConn;
>
>   public void init(ServletConfig conf) throws ServletException {
>     super.init(conf);
>     try{
>       Class.forName("java102.sql.DriverSJ");
>       oracleConn
>=DriverManager.getConnection("jdbc:socket://localhost:5588/jdbc:odbc:Tcp-lo
opback","SCOTT","jack00");
>     }catch (ClassNotFoundException e) {
>       throw new UnavailableException (this,
>      "Couldn't find class: " + e.getMessage ());
>     }catch (SQLException se){
>       System.err.println("SQL Exception caught: " + se);
>     }
>   }
>
>   public void service(HttpServletRequest req, HttpServletResponse res)
>      throws ServletException {
>     int updresult;
>     res.setContentType("text/html");
>     try {
>       ServletOutputStream out = res.getOutputStream();
>       out.println("<html>");
>       out.println("<head>");
>       out.println("<title>Rockmania's JDBC Servlet</title>");
>       out.println("</head>");
>       out.println("<body>");
>       Statement stmt = oracleConn.createStatement();
>       updresult = stmt.executeUpdate("update emp set deptno = 30 where
>empno = 7369");
>       out.println("Rows updated:" +updresult);
>       out.println("</body>");
>       out.println("</html>");
>     } catch(SQLException e) {
>        System.err.println("An SQL Exception was thrown.");
>     } catch(IOException e) {
>        System.err.println("An IOException was thrown.");
>     }
>
>  }
>
>  public void destroy(){
>    try {
>      oracleConn.close();
>    }
>    catch(SQLException e) {
>      System.err.println("An SQL Exception was thrown.");
>    }
>  }
>
>}
>

___________________________________________________________________________
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