Skip to content

sandakith/dropwizard-jdbi

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dropwizard JDBI

Test project for Dropwizard 8 using JDBI to interact with a DB.

Also using Flyway and H2 to create an in memory DB with test data for integration testing. Flyway solution can be expanded to create a fully featured Database Migration process using any JBDC compatible Database you can connect to. Using it here was overkill as I could have just used a simple script, I wanted to try it out as a comparison to Liquibase.

Code for JDBI integration was trivial, most of the effort was getting my head around the fact that I didn't have to do anything to startup the H2 instance (it starts itself as embedded instance when you try to connect to the local DB file by black magic). For reference the most useful stuff is probably in the build.gradle, libraries and plugins used.

Didn't do integration tests as I figured for a real project it would make more sense to do full stack integration testing against the service and the production DB.

Setup H2 DB

Creates an H2 DB populated with the migration scripts in src/main/resources/db/migration

gradle flywayMigrate -i

Run Dropwizard service

To compile:

gradle oneJar

To run:

java -jar build/libs/dropwizard-jdbi-standalone.jar server config.yml

Running the service will start an embedded H2 instance using the person.mv.db file generated by flyway.

To test:

gradle test

About

Simple dropwizard 8 service using JDBI to talk to a DB

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%