may be, check the format of url string
-----Original Message-----
From: John Pallozzi [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 26, 2000 11:07 AM
To: [EMAIL PROTECTED]
Subject: Problem calling Oracle
Hello,
I am trying to do a "proof of concept" exercise where I am trying to call
an Oracle DB and return one row of data, then print it out to the browser
with JSP.
Below is my JSP code, my Bean code, and the error I am receiving. Can
anyone tell me what I am doing wrong?
On a related note I am trying to debug this JSP page using Visual Cafe and
Tomcat and I am receiving an error when the debugger tries to load
org.apache.tomcat.startup.Tomcat.class, it essentially says it can't find
the class. I followed the directions I found at :
http://people.netscape.com/chanezon/tech/java/tomcat/debug_jsp_in_cafe.html
To set up a debug environment for JSP with Visual Cafe and Tomcat, and
still get the same error. Any help there would be greatly appreciated as
well.
JSP CODE:
<%@ page import="java.sql.*" %>
<%@ page import = "helloracle.HelloOracleBean" %>
<jsp:useBean id="nline" class="helloracle.HelloOracleBean" scope="session">
<%
Connection connection = null;
Statement statement = null;
ResultSet results = null;
HelloOracleBean line = new HelloOracleBean();
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
String url = "jdbc:oracle:[EMAIL PROTECTED]";
String email_val = "[EMAIL PROTECTED]";
String query = "SELECT EMAIL, FNAME, LNAME FROM MY_TABLE WHERE EMAIL = " +
email_val;
connection = DriverManager.getConnection(url,"userid","password");
statement = connection.createStatement();
results = statement.executeQuery(query);
if(results.next()) {
nline.setEmail(results.getString("EMAIL"));
nline.setFname(results.getString("FNAME"));
nline.setLname(results.getString("LNAME"));
}
connection.close();
}
catch (ClassNotFoundException e) {
System.err.println("Could not load database driver!");
}
catch (SQLException e) {
System.err.println("Could not connect to the database!");
}
finally{
try { if (connection != null) connection.close(); }
catch (SQLExecption e) {}
}
%>
</jsp:useBean>
<html>
<body>
<table>
<TR>
<TD>Email:</TD>
<TD><jsp:getProperty name="nline" property="email"/></TD>
</TR>
<TR>
<TD>First Name:</TD>
<TD><jsp:getProperty name="nline" property="fname"/></TD>
</TR>
<TR>
<TD>Last Name</TD>
<TD><jsp:getProperty name="nline" property="lname"/></TD>
</TR>
</table>
</body>
</html>
BEAN CODE:
package helloracle;
import java.util.*;
public class HelloOracleBean {
String passed_email;
String passed_fname;
String passed_lname;
public void setEmail(String email) {
passed_email = email;
}
public void setFname(String fname) {
passed_fname = fname;
}
public void setLname(String lname) {
passed_lname = lname;
}
public String getEmail() {
return passed_email;
}
public String getFname() {
return passed_fname;
}
public String getLname() {
return passed_lname;
}
}
ERROR:
Location: /examples/jsp/helloracle/helloemail.jsp
Internal Servlet Error:
org.apache.jasper.JasperException: Unable to compile class for
JSP/jakarta-tomcat/work/localhost_8080%2Fexamples/_0002fjsp_0002fhelloracle_
0002fhelloemail_0002ejsphelloemail_jsp_0.java:124:
Class jsp.helloracle.SQLExecption not found in type declaration.
catch (SQLExecption e) {}
^
1 error
at java.lang.Throwable.(Compiled Code)
at java.lang.Exception.(Compiled Code)
at javax.servlet.ServletException.(Compiled Code)
at org.apache.jasper.JasperException.(Compiled Code)
at org.apache.jasper.compiler.Compiler.compile(Compiled Code)
at org.apache.jasper.runtime.JspServlet.loadJSP(Compiled Code)
at
org.apache.jasper.runtime.JspServlet$JspServletWrapper.loadIfNecessary(Compi
led
Code)
at
org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(Compiled
Code)
at org.apache.jasper.runtime.JspServlet.serviceJspFile(Compiled
Code)
at org.apache.jasper.runtime.JspServlet.service(Compiled Code)
at javax.servlet.http.HttpServlet.service(Compiled Code)
at org.apache.tomcat.core.ServletWrapper.handleRequest(Compiled
Code)
at org.apache.tomcat.core.ContextManager.service(Compiled Code)
at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(Compi
led
Code)
at org.apache.tomcat.service.TcpConnectionThread.run(Compiled
Code)
at java.lang.Thread.run(Compiled Code)
Thanks,
John P.
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets