`
speed_guo
  • 浏览: 311017 次
  • 性别: Icon_minigender_1
  • 来自: 湖北
社区版块
存档分类
最新评论

Blob转String

阅读更多

今天遇到这个问题纠结了半天,哎!总算搞出来了,写点总结吧

1、在类中定义大字段:

public class informAffiche {
   private Blob content;


public void setcontent(Blob S_content)
{
content=S_content;
}
public Blob getcontent()
{
return content;
}

}

 

2、数据库中读取大字段内容并set进去:

while(rs.next())
	{
s.setcontent(rs.getBlob("content"));
}

 

3、在页面得到

if (list.size()>0){
   s=(informAffiche)list.get(0);
 Blob blob= s.getcontent();

if(blob == null || blob.length()==0){
	content = "";
  }else{
	content = new String(blob.getBytes((long)1, (int)blob.length()));
	System.out.println("content---->"+content);
  }


}

 

4、页面输出:

<td><%=content  %></td>

 

 

 

 

 

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics