RT 主要是数据库有一张表中有BLOB 字段,用来存取权限功能 我如果提出这个字段 把它解析出来 得到STRING 就可以 SQL2000

解决方案 »

  1.   

    BLOB对于java中的类型就是byte[],用流来读取:
     public void queryBlob() throws SQLException, IOException{
    Connection conn = null;
    PreparedStatement stmt = null;
    ResultSet rs = null;
    try {
    conn = ConnCreate.getConnection("jdbc:mysql://localhost:3306/test",
    "root", "r66t");
    String sql = "select info from  blob_test where id=3";
    stmt = conn.prepareStatement(sql);
    rs = stmt.executeQuery();
    if(rs.next()){
    InputStream is=rs.getBinaryStream(1);
    File file = new File("d:\\a.bmp");
    OutputStream os = new FileOutputStream(file);
    int len = 0;
    byte[] buffers = new byte[1024];
    while((len=is.read(buffers))>0){
    os.write(buffers, 0, len);
    }
    os.flush();
    os.close();
    is.close();
    }
    } finally {
    ConnCreate.close(conn, stmt, rs);
    }
      

  2.   

    我使用的数据库是OracleBlob blob = rs.getBlob(columnIndex);
    getObjectFromInputStream(blob.getBinaryStream())
    然后你就可以写一个getObjectFromInputStream(InputStream in)方法,
    采用流的方式
      

  3.   

    都能得到byte[]了,还怕不能转换成String???
      

  4.   

    数据库中是blob,但到了程序中转换成string
      

  5.   

    上面打错,,没得到,我现在找不到方法,不知道怎么搞,,QQ273719968  3Q
      

  6.   

    为什么用blob存String,blob应该存图片,文件,视频音频之类的二进制流
      

  7.   

    读出来的 byte[] 好像转String 不行,打印的是一些地址。
      

  8.   

    其实就是一楼说的是  用File  来读取文件。 
      

  9.   

    怎么我byte[]  new string 怎么会是乱码了 纠结一个星期的 blob了,,天天被经理说,,压力大啊,