Eddú Meléndez

Embedded Database Compatibility

Some weeks ago I was watching a video about Spring Testing, one thing that called my attention was one feature about embedded databases. It is about compatibility with other databases.

From my side, this feature is really useful because when I started using embedded database in my tests I had to change some types or remove lines in my script due to there are not supported (At that time, I didn’t know about it)

Lines below you can see how to setup MYSQL compatibility into HSQL and H2 databases, both for testing purpose. Also, you can see the dependencies if you are using maven projects.

HSQL

You can review this link for more information.

script.sql
1
SET DATABASE SQL SYNTAX MYS TRUE;
pom.xml
1
2
3
4
5
6
<dependency>
  <groupId>org.hsqldb</groupId>
  <artifactId>hsqldb</artifactId>
  <version>2.2.8</version>
  <scope>test</scope>
</dependency>

H2

You can review this link for more information.

script.sql
1
SET MODE MySQL;
pom.xml
1
2
3
4
5
6
<dependency>
  <groupId>com.h2database</groupId>
  <artifactId>h2</artifactId>
  <version>1.3.175</version>
  <scope>test</scope>
</dependency>

Comments