O'Reilly logo

Groovy and Grails Recipes by Bashar Abdul-Jawad

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 7Working with Databases

Databases are used in many applications. Java enables developers to connect to and use a database via its Java Database Connectivity (JDBC) API. But JDBC is not simple and requires a lot of coding to achieve the simplest of tasks such as connecting to a database, querying tables, and displaying results. Furthermore, the user is always responsible for managing resources, catching exceptions, and closing connections.

Groovy makes working with databases simpler and more efficient by introducing the groovy.sql library package built on top of JDBC. The groovy.sql library also relieves the user of the burden of managing resources and connections, thanks to closures.

In this chapter, I show you how to use Groovy to connect ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required