11 Replies Latest reply on Aug 19, 2008 4:56 PM by 843785

    retrieveing blob from database and writing to an output file.

      Retrieveing blob from database and writing to an output file which is an EXCEL file.
      if(res.next()) {
                          Blob blobData = res.getBlob("DOCCONTENT"); // retrieving a blob content from the database
                          String srcfileName = res.getString("filename"); //Name of the file I retrieved from the database
                          System.out.println("filename "+srcfileName);
                String fileName = "C:\\Documents and Settings\\Desktop\\blob data\\"+srcfileName; //destination filename
                          FileOutputStream os = new FileOutputStream(fileName);
                          InputStream blobStream = blobData.getBinaryStream();
                          int length = -1;
                     int size = (int)blobData.length();
                     byte[] buffer = new byte[size];
                     while ((length = blobStream.read(buffer)) != -1) {               
                     os.write(buffer, 0, length);

      The output file contains data of incomaptible type and I am not able to open using Excel. What can be possibly wrong?