views:

2553

answers:

1

I tried this code and the value of comments from final table having a clob datatype is null or sometimes displays few words. What should I add so that I retrieve the whole data from comments and displays to the textarea? Thanks:-)

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

<%  Class.forName("oracle.jdbc.driver.OracleDriver"); %>

<HTML>
 <TITLE>SHIFT REPORT </TITLE>
 <BODY BGCOLOR="white">

    <% 
   Connection connection=DriverManager.getConnection ("jdbc:oracle:thin:@oradev2.j.com:1521:RPDB","shiftrpt",  //
         "shiftrpt"
            );

        Statement statement = connection.createStatement() ;
        ResultSet resultset = 
        statement.executeQuery("select * from final") ; 
    %>

    <TABLE BORDER="5" BGCOLOR="PINK" width='270%' cellspacing='1' cellpadding='0' >
        <TR>
            <TH bgcolor='#DAA520'> <font size='2'>RECORD NUMBER</TH>
            <TH bgcolor='#DAA520'><font size='2'>TESTER NUMBER</TH>
            <TH bgcolor='#DAA520'><font size='2'>DATE</TH>
            <TH bgcolor='#DAA520'><font size='2'>TIME</TH>
            <TH bgcolor='#DAA520'><font size='2'>SYSTEM TYPE</TH>
            <TH bgcolor='#DAA520'><font size='2'>PACKAGE</TH>
            <TH bgcolor='#DAA520'><font size='2'>CATEGORY</TH>
       <TH bgcolor='#DAA520'><font size='2'>COMMENTS</TH>
            <TH bgcolor='#DAA520'><font size='2'>VALIDATED BY</TH>
        </TR>

        <% while(resultset.next()){ %>

        <TR bgcolor="#ADDFFF" onMouseOver=this.bgColor="#8AFB17" onMouseOut=this.bgColor="#ADDFFF">
            <TD height="5"> <font size='2'><center><%= resultset.getLong(1) %></center></TD>
            <TD> <font size='2'><center><%= resultset.getString(2) %></center></TD>
            <TD> <font size='2'><center><%= resultset.getDate(3) %></center></TD>
            <TD> <font size='2'><center><%= resultset.getString(4) %></center></TD>
            <TD> <font size='2'><center><%= resultset.getString(5) %></center></TD>
            <TD> <font size='2'><center><%= resultset.getString(6) %></center></TD>
            <TD> <font size='2'><center><%= resultset.getString(7) %></center></TD>
            <TD><font size='2'><center><textarea cols=50 rows=3><%=  resultset.getString(8) %>
            <TD> <font size='2'><center><%= resultset.getString(9) %></center></TD>
        </TR>

        <% } %>


    </TABLE>

  </BODY>
  </HTML>
+1  A: 

Use (java.sql.Clob)resultSet.getObject(8) or resultSet.getClob(8), instead.

Further, its good to look at the example here. Here is the link, Working with LOBs and BFILEs, from Oracle.

Suggestions.

  • Its not a good practice to use scriplets. Use JSP EL/JSTL instead
  • Manipulating result set in JSP is very much discouraged, unless using JSTL SQL tags for prototyping, arguably
Adeel Ansari