Tuesday, December 30, 2014

The H2 database

I installed H2 on my work desktop. I tried to use Spring Data JPA, but ended up making a plain Maven project.

One of the problems that we have in software development is reading and writing information from a database. You don't want to use your regular database for reading, because you'll have to put test data into your regular database. You don't want to use it for writing, because you'll leave your test data on a database.

Enter H2.

The advertising says that I can set it up in memory, load it up with test data in Maven test phase, run my unit tests against it, and then have it all go away when I'm done. 

So far, I have set up a basic in which I start up the H2 database in one window and then run a Java test in my IntelliJ IDE. It's reading the single record from the single table like a champ.

Next step will be to have Maven start up H2, run the test data, and then politely go away. Should be fun.

No comments: