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!

Those are compiler errors because you did not correctly import those classes. Look at your "import" statement - you are missing the "%". You need to carefully read those messages and consider what they are telling you.

Also, please do not post in "chat speak" and do not use excessive CAPS.

Please post the correct syntax about them sir!!

i corrected my code by including % before import java.sql.* package.

The line of code is as follows:-

<%@ page import="java.sql.*" %>
and rest code remaining the same.

I get the following ERRORS now:-

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: An exception occurred processing JSP page /Ora.jsp at line 8

5: <form action="<%=request.getRequestURI() %>" method="POST">
6: <%
7:
8: Class.forName("oracle.jdbc.driver.OracleDriver");
9: Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:student","system", "dexter");
10: Statement st=con.createStatement();
11: ResultSet rs=st.executeQuery("select * from student");


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
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)

root cause

javax.servlet.ServletException: java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:862)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.Ora_jsp._jspService(Ora_jsp.java:81)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
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)

root cause

java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:128)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:66)
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:332)
java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Class.java:186)
org.apache.jsp.Ora_jsp._jspService(Ora_jsp.java:63)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
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)

What to do now??

in your library path check whether you contain class12.jar or not....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.