如何将图片从ORACLE数据库中导出来,存在一个文件夹里面?

来源:百度知道 编辑:UC知道 时间:2024/09/12 21:40:12
数据库为oracle 10g 系统语言采用JAVA编写。
现需要将数据库里面的一个存储图片的表单里面的一部分图片导到数据库外面,存到一个文件夹下面。
请各位高手用详细例子讲解一下,万分感谢。回答结果满意将有高分赠送。

这个是这样,你先用循环读,读成二进制流,然后转文件就可以了

in = rs.getBinaryStream(字段名 );

if (in != null) {

image_out = response.getOutputStream();
response.setContentType("image/jpeg");

byte b[] = new byte[0x7a120];

while (in.read(b) != -1) {
image_out.write(b);
}

try {

//这里改成写文件 image_out.flush();

} catch (Exception e2) {
} finally {
if (in != null) {
in.close();
in = null;
}
if (image_out != null) {
image_out.close();
image_out = null;
}
}
}