Loading
Blob Reading

Java Quick Notes

Refresh Your Java - Before Java Interview

We are Agile, believe in less Documentation - Only Quick notes (Java Interview Questions) of Java/J2ee Read more....


Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet

Go to SiteMap

Q)  What is Blob and How do you read it ?


Ans)

Ans)

A BLOB (Binary Large OBject) is essentially an array of bytes (byte[]), stored in the database. You extract the data in two steps:

    Call the getBlob method of the PreparedStatement class to retrieve a java.sql.Blob object
    Call either getBinaryStream or getBytes in the extracted Blob object to retrieve the java byte[] which is the Blob object.
 
         PreparedStatement stmnt = conn.prepareStatement("select aBlob from BlobTable");
         // Execute
         ResultSet rs = stmnt.executeQuery();
         while(rs.next())
         {
            try
            {
               // Get as a BLOB
               Blob aBlob = rs.getBlob(1);
               byte[] allBytesInBlob = aBlob.getBytes(1, (int) aBlob.length());
            }
            catch(Exception ex)
            {
            }
         }
       rs.close();
       stmnt.close();



Back to top

------------------------- We hope you got necessary Info On -----------------------------------------

Blob Reading


Blob Reading

-------------------------------------------------------------------------------------------------------



Face Book
Request for a Mock Interview/Training

Get a PDF

Face Book
Same look (Read) on any device, this is Ads free