Posted on 2008-09-24 14:01
leekiang 阅读(506)
评论(0) 编辑 收藏 所属分类:
fileupload
1,以下是一些零碎的记录,不全。
//字段为java.sql.Blob类型
Fj fj = new Fj();
fj.setAttblob(Hibernate.createBlob(new byte[1]));//用empty_blob()替换?
session.save(fj);
session.flush();
session.refresh(fj, LockMode.UPGRADE);
org.hibernate.blob.SerializableBlob sb =
(org.hibernate.blob.SerializableBlob) fj.getAttblob();
oracle.sql.BLOB blob = (oracle.sql.BLOB) sb.getWrappedBlob();
OutputStream os = blob.getBinaryOutputStream();
//------
2,用jdbc读取CLOB
http://hi.baidu.com/xh28025/blog/item/f61c2df1ef8130c47831aa70.html
String description = ""
query = "select picstr from clobtest_table where id = '001'";
pstmt = con.prepareStatement(query);
ResultSet result = pstmt.executeQuery();
if(result.next()){
oracle.jdbc.driver.OracleResultSet ors =
(oracle.jdbc.driver.OracleResultSet)result;
oracle.sql.CLOB clobtmp = (oracle.sql.CLOB) ors.getClob(1);
if(clobtmp==null || clobtmp.length()==0){
System.out.println("======CLOB对象为空 ");
description = "";
}else{
description=clobtmp.getSubString((long)1,(int)clobtmp.length());//从1开始?
System.out.println("======字符串形式 "+description);
}
}