Make JDBC in JSP
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Lisa_Tan
Posted On:   Friday, June 6, 2003 09:00 AM

Oracle Connection Page as JSP I have tried to read Oracle data through JDBC in JSP. My jdbc is working when I use Java application but not JSP. The following is my entire code. <%@ page session="false" %> <%@ page import="java.sql.*" %> <%@ page import="java.util.*" %> <% DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); Connection Conn = DriverManager.getConnection("jdbc:oracle:thin:@XXX.wayne.edu:1526:pprd","XXX","XXX"); Statement stmt = Conn.createStatement(); ResultSet rs = stmt.executeQuery("select * fro   More>>
Oracle Connection Page as JSP



I have tried to read Oracle data through JDBC in JSP. My jdbc is working
when I use Java application but not JSP. The following is my entire code.

			
<%@ page session="false" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>






<%

DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection Conn = DriverManager.getConnection("jdbc:oracle:thin:@XXX.wayne.edu:1526:pprd","XXX","XXX");

Statement stmt = Conn.createStatement();


ResultSet rs = stmt.executeQuery("select * from cd");

if (rs==null)
{
System.out.print("not connected
");
}
else {
System.out.print("connected
");
}

while (rs.next ())
{
System.out.print (rs.getString (1) + " ");
System.out.print (rs.getString (2) + " ");
System.out.print (rs.getString (3) + " ");
System.out.print (rs.getString (4) + " ");
System.out.print (rs.getString (5) + "
");
}

// We're done
System.out.print ("done.
");

stmt.close();
Conn.close();
%>



After I ran my code, I have gotten the following error message:

[06/Jun/2003:11:25] info (25620): Internal Info: loading servlet /jsp/lisatan/JdbcTest.jsp
[06/Jun/2003:11:25] info (25620): JSP: JSP1x compiler threw exception
org.apache.jasper.JasperException: Unable to compile class for JSP/opt/pipeline/products/iws6/https-cp/config/../ClassCache/_jsps/_jsp/_lisata
n/_JdbcTest_jsp.java:81: Class oracle.jdbc.driver.OracleDriver not found.
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
^
1 error

at org.apache.jasper.compiler.Compiler.compile(Compiler.java:284)
at com.iplanet.server.http.servlet.NSServletEntity.load(NSServletEntity.java:252)
at com.iplanet.server.http.servlet.NSServletEntity.update(NSServletEntity.java:173)
at com.iplanet.server.http.servlet.NSServletRunner.Service(NSServletRunner.java:416)


[06/Jun/2003:11:25] warning (25620): Internal error: Failed to get GenericServlet. (uri=/jsp/lisatan/JdbcTest.jsp,SCRIPT_NAME=/jsp/lisatan/
JdbcTest.jsp)



Does anyone help me find my bugs? Thanks,

Lisa    <<Less

Re: Make JDBC in JSP

Posted By:   AlessandroA_Garbagnati  
Posted On:   Saturday, June 7, 2003 01:36 AM

Hi,

Put the Oracle JDBC driver in the web application classpath (WEB-INF/lib). If the extension is .zip, change it to .jar.
About | Sitemap | Contact