数据库相关的连接你自己设置,我这的sqlCon是已创建的数据库连接;
代码自己分析,解释两个地方:
1)sql处,根据你自己的表的clob字段修改
2) out.print(getStr(comment));,我这用了一个getStr()方法,那是用来转换内码的;你的代码中若没有该方法,应该再此处去掉
<%
sqlCon.setAutoCommit (false);
java.sql.Clob myClob= null;
String comment="";
int len=0;
Statement stmt = sqlCon.createStatement ();
String sql="select news_body from news where news_id='"+id+"'";
ResultSet rset = stmt.executeQuery (sql);
if (rset.next())
{
myClob= rset.getClob(1);
}
len =(int)myClob.length ();
comment =myClob.getSubString(1,len);
out.print(getStr(comment));
rset.close();
stmt.close();
sqlCon.commit();
}
%>
代码自己分析,解释两个地方:
1)sql处,根据你自己的表的clob字段修改
2) out.print(getStr(comment));,我这用了一个getStr()方法,那是用来转换内码的;你的代码中若没有该方法,应该再此处去掉
<%
sqlCon.setAutoCommit (false);
java.sql.Clob myClob= null;
String comment="";
int len=0;
Statement stmt = sqlCon.createStatement ();
String sql="select news_body from news where news_id='"+id+"'";
ResultSet rset = stmt.executeQuery (sql);
if (rset.next())
{
myClob= rset.getClob(1);
}
len =(int)myClob.length ();
comment =myClob.getSubString(1,len);
out.print(getStr(comment));
rset.close();
stmt.close();
sqlCon.commit();
}
%>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货