Hello mods!!This problem is really frustrating me now!!
i already know about ur tutorial on MVC Connection but i do not want to follow it since it is very complicated for me to understand and implement.
So i have written a code (Ora.jsp) to connect to Oracle XE on my linux machine having FEDORA12 on it.
THE CODE IS AS FOLLOWS:-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Final//EN">
<@ page import="java.sql.*" %>
<html>
<body>
<form action="<%=request.getRequestURI() %>" method="POST">
<%
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:sid","system","dexter");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from student");
while(rs.next())
{System.out.println(rs.getString(1));
}
%>
</form>
</body>
</html>
When i am executing this on my web browser as http://localhost:8080/Ora.jsp then i am getting the following ERRORS:-
type Exception report
message
description 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: 8 in the jsp file: /Ora.jsp
Connection cannot be resolved to a type
5: <form action="<%=request.getRequestURI() %>" method="POST">
6: <%
7: Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
8: Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:sid","system","dexter");
9:
10: Statement st=con.createStatement();
11: ResultSet rs=st.executeQuery("select * from student");
An error occurred at line: 8 in the jsp file: /Ora.jsp
DriverManager cannot be resolved
5: <form action="<%=request.getRequestURI() %>" method="POST">
6: <%
7: Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
8: Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:sid","system","dexter");
9:
10: Statement st=con.createStatement();
11: ResultSet rs=st.executeQuery("select * from student");
An error occurred at line: 10 in the jsp file: /Ora.jsp
Statement cannot be resolved to a type
7: Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
8: Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:sid","system","dexter");
9:
10: Statement st=con.createStatement();
11: ResultSet rs=st.executeQuery("select * from student");
12: while(rs.next())
13: {System.out.println(rs.getString(1));
An error occurred at line: 10 in the jsp file: /Ora.jsp
con cannot be resolved
7: Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
8: Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:sid","system","dexter");
9:
10: Statement st=con.createStatement();
11: ResultSet rs=st.executeQuery("select * from student");
12: while(rs.next())
13: {System.out.println(rs.getString(1));
An error occurred at line: 11 in the jsp file: /Ora.jsp
ResultSet cannot be resolved to a type
8: Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:sid","system","dexter");
9:
10: Statement st=con.createStatement();
11: ResultSet rs=st.executeQuery("select * from student");
12: while(rs.next())
13: {System.out.println(rs.getString(1));
14: }
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:586)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
MY QUESTION IS HOW TO RUN THIS JSP TO CONNECT 2 ORACLE????
IS THERE ANY NEED 2 HAVE A DSN ON FEDORA AS WE DID IT IN WINDOWS FOR CONNECTING TO ORACLE???
PLZZ DO REPLY PEOPLE!!I AM REALLY STUCK ON IT FOR MANY DAYS NOW!