Working with databases
We won't be able to progress much further without the ability to save our objects, namely cats, into some kind of persistent storage.
For that, we'll need to connect to the database first.
Add the following two lines to your build.gradle
dependencies section:
compile group: 'org.postgresql', name: 'postgresql', version: '42.2.2' compile group: 'io.vertx', name: 'vertx-jdbc-client', version: $vertx_version
The first line of code fetches the PostgreSQL
driver. The second one adds the Vert.x JDBC client, which allows Vert.x, having the driver, to connect to any database that supports JDBC.
Managing configuration
Now we want to hold database configuration somewhere. For local development, it may be fine to have those configurations hardcoded.
When we connect to the database, we need to specify the following parameters at the very least:
- Username
- Password
- Host
- Database name
Where should we store them?
One option is of course to hardcode those values. That would be fine for a local...