我尝试了此代码, clob 数据类型的最终表格中评论的值为null或有时会显示几个字。我应该添加什么以便从评论中检索整个数据并显示到textarea?谢谢:-)
<%@ 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>
答案 0 :(得分:1)
使用(java.sql.Clob)resultSet.getObject(8)或 resultSet.getClob(8)。
此外,有必要查看example here。以下是来自Oracle的链接Working with LOBs and BFILEs。
<强>建议。强>