Interacting with the database

Now we have a database and data in place. However, in order to be able to connect to the database, we need to include the mysql jdbc connector in the project. Also, we will need the dropwizard-jdbi module that will allow us to create a database connection and Data Access Objects (DAO) through which we will query the database, making use of the API provided by the JDBI project (http://jdbi.org/).

Getting ready

Let's see what is needed in order to achieve this. First, add the following dependencies in pom.xml within the <dependencies> section:

<dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>5.1.6</version></dependency><dependency><groupId>io.dropwizard</groupId><artifactId>dropwizard-jdbi</artifactId><version>0.7.0-SNAPSHOT</version></dependency> ...

Get RESTful Web Services with Dropwizard now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.