Refresh Your Java - Before Java Interview
We are Agile, believe in less Documentation - Only Quick notes (Java Interview Questions) of Java/J2ee Read more....
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();
This Portal is intended to put all Java/J2ee related topics at one single place for quick referance, not only Technical , but also the Project Management Related thing such as Development Process methodoogies build process, unit testing etc.,
This Portal has More than 500 Java Interview Questions (also could be Considered as Quick Notes) very neatly separated topic by topic with simple diagrams which makes you easily understandable. Importantly these are from our Realtime expericance.