Easy Java database with Maven plugin to start / stop?

For unit tests, demos, and Hibernate tasks, I would like to use a small and simple Java database such as Derby / Java DB or HSQLDB, which can be called from Maven.

So far, I have not found a Maven plugin that can load and run Java DB (which is now my favorite) or something like that.

+5
source share
3 answers

A simple setup for unit tests is to run hsqldb in memory :

db.connection.driver_class=org.hsqldb.jdbcDriver
db.connection.url=jdbc:hsqldb:mem:aname
db.connection.username=sa
db.connection.password=
hibernate.dialect=org.hibernate.dialect.HSQLDialect

No need to start and stop. The JDBC driver will start the database.

You can also use this for demos. If you initialize the database during application startup.

Database tuning can be done using hibernate.hbm2ddl.auto .


Edit by kdgregory:

To enable Maven to enable HSQLDB depending only on the test phase, use this in your POM:

<dependency>
    <groupId>hsqldb</groupId>
    <artifactId>hsqldb</artifactId>
    <version>1.8.0.7</version>
    <scope>test</scope>
</dependency>
+6
source

, Derby derby-maven-plugin, GitHub Maven Central. Derby , CI - , Maven.

+2

, , , SQLite , , , . .

0

All Articles