Reading BLOB/CLOB from a database

Large binary object types are meant to store data, which is otherwise not splittable into relational tables and columns, or which is easier to store in a binary form for application-specific or performance needs. Groovy does not offer any special methods for handling SQL's large binary objects, but, on the other hand, this recipe will show how to apply Groovy's I/O API extensions to make the code more readable.

Getting ready

Let's again use the database model we created in the Creating a database table recipe. In the RECIPE table, we have the DESCRIPTION column of CLOB type and the IMAGE column of BLOB type.

How to do it...

To read the data, we can just use the same query methods we used in the Querying an SQL database ...

Get Groovy 2 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.