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...
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:
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();
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());
}