0 Replies Latest reply on Jul 27, 2004 11:17 PM by anil kumar

    How to connect to DB2 on SunBlade server with JBOSS on Win P

    anil kumar Newbie

      Someone Plz help me, URGENT:

      is there any thing wrong with this JSP code :

      file name: login1.jsp:

      <%@ page language="java" import="java.sql.*" %>




      <%java.sql.Connection conn=null;
      try {

      javax.naming.Context ctx = new javax.naming.InitialContext();
      javax.sql.Datasource ds = (javax.sql.DataSource)ctx.lookup("jdbc/DB2DS");
      conn = ds.getConnection();

      java.sql.Satement stmt = conn.createStaement();
      java.sql.ResultSet rs = stmt.executeQuery("Select * from login");

      while (rs.next()){

      out.println(rs.getString("LOGID"));
      out.println(rs.getString("PWD"));

      }

      rs.close();
      stmt.close();

      }catch (Exception e){
      System.out.println("Service Error: "+e);
      }finally {
      if (conn !=null)
      try {
      conn.close();
      } catch (Exception ignore) {};
      }
      %>





      when I run it, the errors page it throws is:

      HTTP Status 500 -

      --------------------------------------------------------------------------------

      type Exception report

      message

      description The server encountered an internal error () that prevented it from fulfilling this request.

      exception

      org.apache.jasper.JasperException: Unable to compile class for JSP

      An error occurred at line: 6 in the jsp file: /login1.jsp
      Generated servlet error:
      C:\Migrations\jboss-3.2.5\server\default\work\jboss.web\localhost\MyGreeting6\org\apache\jsp\login1_jsp.java:52: cannot resolve symbol
      symbol : class Datasource
      location: package sql
      javax.sql.Datasource ds = (javax.sql.DataSource)ctx.lookup("jdbc/DB2DS");
      ^


      An error occurred at line: 6 in the jsp file: /login1.jsp
      Generated servlet error:
      C:\Migrations\jboss-3.2.5\server\default\work\jboss.web\localhost\MyGreeting6\org\apache\jsp\login1_jsp.java:55: cannot resolve symbol
      symbol : class Satement
      location: package sql
      java.sql.Satement stmt = conn.createStaement();
      ^


      An error occurred at line: 6 in the jsp file: /login1.jsp
      Generated servlet error:
      C:\Migrations\jboss-3.2.5\server\default\work\jboss.web\localhost\MyGreeting6\org\apache\jsp\login1_jsp.java:55: cannot resolve symbol
      symbol : method createStaement ()
      location: interface java.sql.Connection
      java.sql.Satement stmt = conn.createStaement();
      ^
      3 errors



      org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
      org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:332)
      org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:412)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
      org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:810)


      note The full stack trace of the root cause is available in the Apache Tomcat/5.0.26 logs.


      --------------------------------------------------------------------------------

      Apache Tomcat/5.0.26