- 19
- 0
- 约1.7万字
- 约 53页
- 2016-12-27 发布于贵州
- 举报
基于jsp访问oracle数据库blob字段并显示图形的解决方案
篇一:从数据库中读取Blob对象图片并显示
从数据库中读取Blob对象图片并显示
第一种方法:
大致方法就是,从数据库中读出Blob的流来,写到页面中去:
Connection conn = DBManager.getConnection();
String sql = SELECT picture FROM teacher WHERE id=1;
PreparedStatement ps = null;
ResultSet rs = null;
InputStream is = null;
OutputStream os = null;
try {
ps = conn.prepareStatement(sql);
rs = ps.executeQuery();
if(rs.next()){
is = rs.getBinaryStream(1);
}
response.setContentType(text/html);
os = response.getOutputStream();
int num;
byte buf[] = new byte[1024];
while((num=is.read(buf))!=-1){
os.write(buf, 0, nu
原创力文档

文档评论(0)