-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Groovy 2 Cookbook
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.
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.
To read the data, we can just use the same query methods we used in the Querying an SQL database recipe:
sql.eachRow('SELECT * FROM RECIPE') { recipe ->
println recipe.description.characterStream.text
def recipeImage = new File("recipe-${recipe.id}.jpg")
recipeImage.delete()
recipeImage << recipe.image.binaryStream
}
Change the font size
Change margin width
Change background colour