Oracle中long|Oracle中long raw 类型数据读取

在oracle数据库中,某表的图片以long raw类型存着,想要把这个数据通过程序下载到本地或者导入到数据库其他表.费了好大劲才尝试出的方法,做下记录.
if(conn == null){
this.getConn();
}
【Oracle中long|Oracle中long raw 类型数据读取】byte[] data = https://www.it610.com/article/null;
FileOutputStream os=new FileOutputStream("d:/1.jpg");
PreparedStatement ps=null;
ResultSet rs=null;
//photo是该照片的字段(类型long raw)
String sql="select photo from table t where t.id=?";
try {
ps=conn.prepareStatement(sql);
ps.setString(1, id);
rs=ps.executeQuery();
while(rs.next()){
data=https://www.it610.com/article/rs.getBytes("photo");
}
os.write(data); //存到指定位置; 需要存入数据表的话,将data返回即可操作.
关闭资源...

    推荐阅读