Show TOC

Background documentationUsing LOBs Locate this document in the navigation structure

 

For storing very large datasets, database vendors provide large object data types (LOB), which are available with two different characteristics. The data type CLOB is for the administration of character strings of up to 357,913,941 characters. The data type BLOB is for the administration of byte sequences of up to 1,073,741,824 bytes. An example of where LOBs are used is for storing graphics in the database.

Note Note

LOBs are not allowed to have the length 0 due to database limitations.

End of the note.

Features

The JDBC API provides methods for working with LOBs. You can retrieve data from and write data to CLOB and BLOB using:

  • the getBytes() or getString()methods of java.sql.ResultSet, and setBytes() or setString() methods of java.sql.PreparedStatement - this enables reading and writing data en bloc

  • the getBlob()or getClob() methods of java.sql.ResultSet, and setBlob() or setClob() methods of java.sql.PreparedStatement - in this case you use locators to operate with LOBs

  • the getBinaryStream()or getCharacterStream() methods of java.sql.ResultSet, setBinaryStream()or setCharacterStream() methods of java.sql.PreparedStatement, as well as sqlj.runtime.BinaryStream and sqlj.runtime.CharacterStream - you read and write data in streams.