View Single Post
  #1 (permalink)  
Old March 8th, 2004, 06:16 PM
Javahead Javahead is offline
Registered User
Join Date: Mar 2004
Location: Luton, Beds, United Kingdom.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default problems with examples

    i tried to run the program written on chapter 13 in page 492. i wrote a similar program but if i run it, it shows error. can anyone help me please.Here's my code:

package com;

import java.sql.*;

public class mysql1

  int id=0;
  int account_no=0;
  String pass="";

  public void init()
      Connection con = null;
      Statement st = null;
      ResultSet rs = null;

       Class.forName("com.mysql.jdbc.Driver").newInstance ();
       con = DriverManager.getConnection("jdbc:mysql:///password",
        "root", "firehouse");

       st = con.createStatement();
       rs = st.executeQuery("SELECT id, account_no, password FROM pass");

         id = rs.getInt(1);
         account_no = rs.getInt(2);
         pass = rs.getString(3);
         //System.out.println(userId + ". " + lastName + ", " + firstName + " ");

     } catch (Exception e)
         System.err.println("Exception: " + e.getMessage());


            if(rs != null)
            if(st != null)
            if(con != null)
          } catch (SQLException e)

 public int getId()
    return id;

 public int getAccountNo()
    return account_no;
 public String getPass()
    return pass;

 }// class ends

jsp page:

   <title>Checking pass</title>
  com.mysql1 qdb = new com.mysql1();

<h2>Query Result</h2>
Account No: <%qdb.getAccount_no()%>
Password: <%qdb.getPass()%>



but i get the following error when i run it:

org.apache.jasper.JasperException: Unable to compile class for JSP
No Java compiler was found to compile the generated source for the JSP.
This can usually be solved by copying manually $JAVA_HOME/lib/tools.jar from the JDK
to the common/lib directory of the Tomcat server, followed by a Tomcat restart.
If using an alternate Java compiler, please check its installation and access path.

    org.apache.jasper.compiler.DefaultErrorHandler.jav acError(
    org.apache.jasper.compiler.ErrorDispatcher.javacEr ror(
    org.apache.jasper.servlet.JspServletWrapper.servic e(
    org.apache.jasper.servlet.JspServlet.serviceJspFil e(
    javax.servlet.http.HttpServlet.service(HttpServlet .java:856)

Reply With Quote