Forums Register Login

Problem loading the class

+Pie Number of slices to send: Send

HEY I WROTE THIS CODE and i am getting the following error.
i am not understanding what the error is..i m trying to connect to my database and display the values of the table...
+Pie Number of slices to send: Send
What error you are getting?

Change this

to


and move it to top of the jsp.

Hopefully this might help
+Pie Number of slices to send: Send
i made changes but i m still getting errors in the code..


the errors are as follows:
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 generated java file
Only a type can be imported. java.sql resolves to a package

An error occurred at line: 7 in the jsp file: /sql1.jsp
Connection cannot be resolved to a type
4: <%@ page import="java.sql,com.conn.*,java.sql.ResultSet" %>
5: <%
6: String url = "jdbc:postgresql://localhost/Books";
7: Connection con;
8: ResultSet rs;
9: String s;
10: Statement st;


An error occurred at line: 10 in the jsp file: /sql1.jsp
Statement cannot be resolved to a type
7: Connection con;
8: ResultSet rs;
9: String s;
10: Statement st;
11: String sqlstr = "SELECT \"ID\",\"Book Name\",\"Author\" FROM public.books_details";
12:
13: try


An error occurred at line: 25 in the jsp file: /sql1.jsp
DriverManager cannot be resolved
22:
23: try
24: {
25: con = DriverManager.getConnection(url,"postgres", "admin123");
26:
27: st = con.createStatement();
28: rs = st.executeQuery(sqlstr);


An error occurred at line: 41 in the jsp file: /sql1.jsp
SQLException cannot be resolved to a type
38: con.close();
39:
40: }
41: catch(SQLException ex)
42: {
43: System.err.println("SQLException: " + ex.getMessage());
44: }


An error occurred at line: 43 in the jsp file: /sql1.jsp
ex cannot be resolved
40: }
41: catch(SQLException ex)
42: {
43: System.err.println("SQLException: " + ex.getMessage());
44: }
45:
46:


Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:312)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:299)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:589)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


note The full stack trace of the root cause is available in the Apache Tomcat/6.0.24 logs.
+Pie Number of slices to send: Send
your code is not formatted , it is difficult to read. please edit your post to use code tag to post gain
+Pie Number of slices to send: Send
 

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 generated java file
Only a type can be imported. java.sql resolves to a package

An error occurred at line: 7 in the jsp file: /sql1.jsp
Connection cannot be resolved to a type
<%@ page import="java.sql,com.conn.*,java.sql.ResultSet" %>
<%
String url = "jdbc:postgresql://localhost/Books";
Connection con;
ResultSet rs;
String s;
Statement st;


An error occurred at line: 10 in the jsp file: /sql1.jsp
Statement cannot be resolved to a type
Connection con;
ResultSet rs;
String s;
Statement st;
String sqlstr = "SELECT \"ID\",\"Book Name\",\"Author\" FROM public.books_details";

try


An error occurred at line: 25 in the jsp file: /sql1.jsp
DriverManager cannot be resolved

try
{
con = DriverManager.getConnection(url,"postgres", "admin123");

st = con.createStatement();
rs = st.executeQuery(sqlstr);


An error occurred at line: 41 in the jsp file: /sql1.jsp
SQLException cannot be resolved to a type
con.close();

}
catch(SQLException ex)
{
System.err.println("SQLException: " + ex.getMessage());
}


An error occurred at line: 43 in the jsp file: /sql1.jsp
ex cannot be resolved
}
catch(SQLException ex)
{
System.err.println("SQLException: " + ex.getMessage());
}


Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:312)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:299)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:589)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


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

 
+Pie Number of slices to send: Send
still your import statement is not correct


by the way: use code tag instead of quote tag while posting code .
+Pie Number of slices to send: Send
You have to fix your imports, Statement interface is inside java.sql package.
So fix it by by changing it to java.sql.* as below.
When I was younger I felt like a man trapped inside a woman’s body. Then I was born. My twin is a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 2760 times.
Similar Threads
Reuse an object?
Iterator
delete row from database
Servlet Problem with JDBC
how to display values from database in a dropdown box?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 20:18:26.