Discussions
Categories
- 385.5K All Categories
- 5.1K Data
- 2.5K Big Data Appliance
- 2.5K Data Science
- 453.4K Databases
- 223.2K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 47 Multilingual Engine
- 606 MySQL Community Space
- 486 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3.2K ORDS, SODA & JSON in the Database
- 585 SQLcl
- 4K SQL Developer Data Modeler
- 188K SQL & PL/SQL
- 21.5K SQL Developer
- 46 Data Integration
- 46 GoldenGate
- 298.4K Development
- 4 Application Development
- 20 Developer Projects
- 166 Programming Languages
- 295K Development Tools
- 150 DevOps
- 3.1K QA/Testing
- 646.7K Java
- 37 Java Learning Subscription
- 37.1K Database Connectivity
- 201 Java Community Process
- 108 Java 25
- 22.2K Java APIs
- 138.3K Java Development Tools
- 165.4K Java EE (Java Enterprise Edition)
- 22 Java Essentials
- 176 Java 8 Questions
- 86K Java Programming
- 82 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 208 Java User Groups
- 25 JavaScript - Nashorn
- Programs
- 667 LiveLabs
- 41 Workshops
- 10.3K Software
- 6.7K Berkeley DB Family
- 3.6K JHeadstart
- 6K Other Languages
- 2.3K Chinese
- 207 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 474 Portuguese
org.apache.jasper.JasperException: Unable to compile class for JSP:

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:
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
-
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
-
So Db.db cannot be resolved to a type.
Did you forget to declare it? or omit an import? -
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"%> -
So where is the declaration of Db.db? Or Db itself for that matter?
-
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();
}
}
} -
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.