我要在sql 2000中存入图片,然后再读取出来,要怎么搞

解决方案 »

  1.   

    在表中建一Blob字段,存数据库时将图片转换成字节流,存到数据库中
    FileInputStream stream = new FileInputStream(new File(filePath));
    byte[] buffer = new byte[stream.available()];
    stream.read(buffer);
    product.setPhoto(Hibernate.createBlob(buffer));
    stream.close();
      

  2.   

    有两种方式:1,只保存路径在数据库,需要时再根据路径去找图片。2,使用Blob格式保存图片
    -------------
    推荐第1种。第二种会加重服务器。
      

  3.   

    将图片 转成二进制流,在数据库中用image类型 存储。