In addition to numbers, strings, and dates, many databases can store large objects (LOBs) such as images or other data. In SQL, binary large objects are called BLOBs, and character large objects are called CLOBs.
To read a LOB, execute a
SELECT statement and call the
getClob method on the
ResultSet. You will get an object of type
Clob. To get the binary data from a
Blob, call the
getBinaryStream. For example, if you have a table with book cover images, you can retrieve an image like this:
PreparedStatement stat = conn.prepareStatement("SELECT Cover FROM BookCovers WHERE ISBN=?"); stat.set(1, isbn); ResultSet result = stat.executeQuery();
if (result.next()) ...