• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Problem loading the class

 
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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...
 
Ranch Hand
Posts: 45
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What error you are getting?

Change this

to


and move it to top of the jsp.

Hopefully this might help
 
maggie karve
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 coderanch.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.
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
your code is not formatted , it is difficult to read. please edit your post to use code tag to post gain
 
maggie karve
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 coderanch.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.

 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
still your import statement is not correct


by the way: use code tag instead of quote tag while posting code .
 
Balraj Momi
Ranch Hand
Posts: 45
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic