日期:2014-05-17 浏览次数:20633 次
import java.io.FileOutputStream; import java.io.InputStream; import java.sql.ResultSet; import com.ac990.util.DbMainUtil; public class OLEDemo extends DbMainUtil{ public void blobRead(String outfile){ DbMainUtil dbUtil = new DbMainUtil(); try { String strsql = "select * from tb201101_spda where f_bm = '001'" ; ResultSet rs = dbUtil.query(strsql); while (rs.next()) { InputStream image = rs.getBinaryStream(24); FileOutputStream file1 = null; file1 = new FileOutputStream("d:/100.jpg"); int chunk; while ((chunk = image.read()) != -1){ file1.write(chunk); } file1.flush(); file1.close(); } } catch (Exception e) { e.printStackTrace(); } finally { dbUtil.cloes(); } } public static void main(String[] args) { try { OLEDemo gi=new OLEDemo(); } catch (Exception e) { System.out.println("[Main func error: ]" + e.getMessage()); } } }