@Override
public String getFormViewById(final String id) {
return (String)getHibernateTemplate().execute(new HibernateCallback<Object>(){
public Object doInHibernate(Session session) throws HibernateException, SQLException {
String sql = "select formView from sys_forms where id='" + id + "'";
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
String content = "";
try {
conn = session.connection();
stmt = conn.prepareStatement(sql);
rs = stmt.executeQuery();
while(rs.next()){
Blob blob = (Blob) rs.getBlob("formView");
int bolblen = (int) blob.length();
byte[] data = blob.getBytes(1, bolblen);
content = new String(data,"utf-8");
}
}finally{
conn.close();
stmt.close();
}
return content;
}
});
}
读取数据库中BLOB字段
最新推荐文章于 2024-07-19 03:26:05 发布