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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access