從ORACLE 生成圖片

imlihj2007發表於2008-02-29
public static void printPic()throws SQLException{
ResultSet rs=null;
Connection conn=null;
Statement stmt=null;
try {
//從ORACLE 生成圖片
conn=getConn();
stmt=conn.createStatement();
rs=stmt.executeQuery("select zp from jczhxxgl.rk_zzrk where dbms_lob.getlength(zp)>0 and rownum<6");
int i=0;
while(rs.next()){
InputStream fi=null;
Blob blob = rs.getBlob("zp");
FileOutputStream outSTr = new FileOutputStream(new File("c:lll"+i+".jpg"));
i+=1;
BufferedOutputStream Buff=new BufferedOutputStream(outSTr);
Buff.write(blob.getBytes(1, (int)blob.length()));
Buff.flush();
Buff.close();


}
}
catch (Exception ex) {
ex.printStackTrace();
}
finally{
//rs.close();
stmt.close();
conn.close();
}

}

[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9879835/viewspace-1000180/,如需轉載,請註明出處,否則將追究法律責任。

相關文章