Hello,

>From a JSP page I am trying to query an Oracle database and retrieve a CLOB
field. I want to then convert the CLOB to a string and set it in a
javabean.  Right now I am receiving a org.apache.jasper.JasperException
when i try to bring the JSP page up in a browser. I think I'm close, I
think the code might be all right, but I might be missing a key package in
the import statements. Below is the JSP code, the bean, and the Exception,
any help would be gretly appreciated, I'm in a bit of a spot.

Thanks,

John P.


JSP CODE:

<%@ page import="java.net.URL" %>
<%@ page import="oracle.sql.*" %>
<%@ page import="java.sql.*" %>
<%@ page import = "helloracle.HelloOracleBeanClob" %>
<jsp:useBean id="brandnewline" class="helloracle.HelloOracleBeanClob">
<%

Connection connection = null;
Statement statement = null;
ResultSet results = null;


// HelloOracleBean line = new HelloOracleBean();
brandnewline.setTestvar();

try{

Class.forName("oracle.jdbc.driver.OracleDriver");
String url = "jdbc:oracle:thin:@ipaddress:dbname";
String query = "SELECT FIELD1, CLOB_FIELD FROM TABLE WHERE OTHER_FIELD
= 'some text'";
connection = DriverManager.getConnection(url,"userid","password");
statement = connection.createStatement();
results = statement.executeQuery(query);

if(results.next()) {

     Clob localclob = results.getClob("CLOB_FIELD");
     long len = localclob.length();
     String clobstring = localclob.getSubString(1,len);

     brandnewline.setXML(clobstring);
     brandnewline.setSerieseq(results.getString("FIELD1"));


     }

     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 (SQLException e) {}

}



%>
</jsp:useBean>
<html>
<body>
<table>
<TR>
<TD>XML:
<jsp:getProperty name="brandnewline" property="XML"/>
</TD>
<TD>
</TR>
<TR>
<TD>Stuff:
<jsp:getProperty name="brandnewline" property="testvar"/></TD>
<TD>
</TD>
</TR>
<TR>
<TD>SERIES SEQ:
<jsp:getProperty name="brandnewline" property="serieseq"/></TD>
<TD>
</TD>
</TR>
</table>
</body>
</html>


BEAN CODE:


package helloracle;

import java.util.*;

public class HelloOracleBeanClob {

     private String passed_clob;
     private String passed_series_seq;
     private String test_var;

  public void setXML(String myclob) {

     passed_clob = myclob;

     }

  public void setSerieseq(String myseries_seq) {

    passed_series_seq = myseries_seq;

     }


  public void setTestvar() {

    test_var = "blahblah";

     }


  public String getXML() {

    return passed_clob;
  }

   public String getSerieseq() {

      return passed_series_seq;
  }

  public String getTestvar() {

      return test_var;
  }

}


EXCEPTIONS:

Internal Servlet Error:

org.apache.jasper.JasperException: Unable to compile class for JSPC:
\jakarta-tomcat\work\localhost_8080%2Fexamples\_0002fjsp_0002fhelloracle_0002fhelloart_0002ejsp_0002fjsp_0002fhelloracle_0002fhelloart_jsp_20.java:116:

Class Clob not found in type declaration.
                        Clob localclob = results.getClob("CLOB_FIELD");
                        ^
C:
\jakarta-tomcat\work\localhost_8080%2Fexamples\_0002fjsp_0002fhelloracle_0002fhelloart_0002ejsp_0002fjsp_0002fhelloracle_0002fhelloart_jsp_20.java:116:

Method getClob(java.lang.String) not found in interface java.sql.ResultSet.
                        Clob localclob = results.getClob("CLOB_FIELD");
                                                        ^
2 errors

        at java.lang.Throwable.(Compiled Code)
        at java.lang.Exception.(Compiled Code)
        at javax.servlet.ServletException.(ServletException.java:107)
        at org.apache.jasper.JasperException.(JasperException.java:73)
        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(Compiled

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(Compiled

Code)
        at org.apache.tomcat.service.TcpConnectionThread.run(Compiled Code)
        at java.lang.Thread.run(Compiled Code)

===========================================================================
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

Reply via email to