mysql,sqlserver,oracle三种数据库的大对象存取(4)
来源:未知 责任编辑:责任编辑 发表时间:2014-03-23 22:31 点击:次
ps.close();
}
else {
//取出
PreparedStatement ps = conn.prepareStatement("select * from tb_file where filename = ?");
ps.setString(1, "aaa.exe");
ResultSet rs = ps.executeQuery();
rs.next();
InputStream in = rs.getBinaryStream("filecontent");
System.out.println(in.available());
FileOutputStream out = new FileOutputStream("d:/bbb.exe");
byte[] b = new byte[1024];
int len = 0;
while ( (len = in.read(b)) != -1) {
out.write(b, 0, len);
out.flush();
}
out.close();
in.close();
rs.close();
ps.close();
}
}
catch (Exception ex) {
ex.printStackTrace(System.out);
}
finally {
try {
conn.close();
}
catch (Exception ex) {}
}
}
}
摘自 Mars学IT
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>