日期:2014-05-19  浏览次数:20637 次

读取不到oracle中的Blob数据是怎么回事?
public void getblob(){
  OutputStream os;
  Session ss=ht.getSessionFactory().openSession();
  PhotoAlbum pa=(PhotoAlbum) ss.get(PhotoAlbum.class, 11700);
  Blob gb=pa.getSb();
  try{
  try{
  InputStream is=gb.getBinaryStream(); //这里获取的流长度是零 是怎么原因
  }catch(SQLException eq){ //数据库中是有记录的
  eq.printStackTrace();
  }
  os=new FileOutputStream("/home/oracle/照 片/t.jpg");
   
  byte[] by=new byte[1024];
  int len ;
  while((len=is.read(by))!=-1){
  System.out.println(len);
  os.write(by,0,len); 写出来的文件是空的
  }
  is.close();
  os.close();
  }catch(IOException e){
  e.printStackTrace();
  }
   
  }

------解决方案--------------------
ORACLE BLOB 和HIBERNATE 整合有问题 百度一下吧