Chapter 7. Working with Databases in Groovy

In this chapter, we will cover:

  • Creating a database table
  • Connecting to an SQL database
  • Querying an SQL database
  • Modifying data in an SQL database
  • Calling a stored procedure
  • Reading BLOB/CLOB from a database
  • Building a simple ORM framework
  • Using Groovy to access Redis
  • Using Groovy to access MongoDB
  • Using Groovy to access Apache Cassandra

Introduction

The group of recipes presented in this chapter deals with data persistence, either through a relational SQL database or a NoSQL database.

The first recipe describes how to access and modify data stored in a relational database, such as Oracle or MySQL. Groovy makes accessing data using the SQL language a very elegant affair, compared to the clunky Java's JDBC APIs.

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.