This site is currently read-only as we are migrating to Oracle Forums for an improved community experience. You will not be able to initiate activity until January 30th, when you will be able to use this site as normal.

    Forum Stats

  • 3,890,088 Users
  • 2,269,775 Discussions
  • 7,916,823 Comments

Discussions

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

891428
891428 Member Posts: 7
Hii,

Any idea on this error?

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

An error occurred at line: 16 in the jsp file: /1d0258c2440a8d19e716292b231e3190/delete_item_action.jsp
Db.db cannot be resolved to a type
13: for(int i=0; i<count;i++)
14: {
15: if(request.getParameter("checkbox_"+i).equals("delete"))
16: Db.db.setUpdate("Update hardware set d_status=1 where hardware_Id="+request.getParameter("Id_"+i)+";");
17:
18:

Best Answer

  • EJP
    EJP Member Posts: 32,943 Gold Crown
    Answer ✓
    Java is case sensitive, didn't you know that? DB amd Db are two different things to Java, and a class called db must be in a file called db.java; conversely a file called DB.java must contain a class called DB. You need to sort all this out, it is a complete mess at the moment.

Answers

  • EJP
    EJP Member Posts: 32,943 Gold Crown
    So Db.db cannot be resolved to a type.

    Did you forget to declare it? or omit an import?
  • 891428
    891428 Member Posts: 7
    Hi,

    I have done the following at the top of the page. Do I miss out something?

    <%@ page import="java.util.*"%>
    <%@ page import="java.lang.*"%>
    <%@ page language="java" import="DB.*" %>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
  • EJP
    EJP Member Posts: 32,943 Gold Crown
    edited Sep 29, 2011 4:21AM
    So where is the declaration of Db.db? Or Db itself for that matter?
  • 891428
    891428 Member Posts: 7
    The page is located at web/test/test.jsp and the java as below
    Is there anything still need to add to test.jsp?

    DB.java (web/classes/DB/db.class)
    ------------------------------------------------------------------------------
    package DB;
    import java.sql.*;

    public class db
    {
    String db_url="jdbc:mysql://localhost:3306/DB";
    String db_user="root";
    String db_password="123456";
    private ResultSet r=null;
    static private ResultSet res=null;
    int staff_Id=0;

    /** Creates a new instance of db */

    public int getRetrieveId()
    {
    try{
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    }
    catch (Exception E)
    {
    E.printStackTrace();
    }
    try{
    Connection C = DriverManager.getConnection(db_url,db_user,db_password);
    Statement S = C.createStatement();
    r = S.executeQuery("select max(staff_Id) from staff");
    while(r.next()){
    staff_Id=r.getInt(1);
    }
    S.close();
    C.close();

    }
    catch(Exception e)
    {
    e.printStackTrace();
    }
    return staff_Id;
    }

    public static boolean getSearch(String s)
    {
    String search_db_url="jdbc:mysql://localhost:3306/DB";
    String search_db_user="root";
    String search_db_password="123456";
    String str=null;
    boolean result=false;

    try{
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    }
    catch (Exception E)
    {
    E.printStackTrace();
    }
    try{
    Connection C = DriverManager.getConnection(search_db_url,search_db_user,search_db_password);
    Statement S = C.createStatement();
    res = S.executeQuery(s);
    while(res.next()){
    str=res.getString(1);
    }
    if(!str.equals(null))
    {
    result=true;
    }
    S.close();
    C.close();

    }
    catch(Exception e)
    {
    e.printStackTrace();
    }
    return result;
    }


    public void setUpdate(String str)
    {
    try{
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    }
    catch (Exception E)
    {
    E.printStackTrace();
    }
    try{
    Connection C = DriverManager.getConnection(db_url,db_user,db_password);
    Statement S = C.createStatement();
    int r = S.executeUpdate(str);
    S.close();
    C.close();

    }
    catch(Exception e)
    {
    e.printStackTrace();
    }
    }

    }
  • EJP
    EJP Member Posts: 32,943 Gold Crown
    Answer ✓
    Java is case sensitive, didn't you know that? DB amd Db are two different things to Java, and a class called db must be in a file called db.java; conversely a file called DB.java must contain a class called DB. You need to sort all this out, it is a complete mess at the moment.
This discussion has been closed.