wannabeartist
wannabeartist

Reputation: 2833

Is it possible to use mysql dump for populating hsqldb database?

I'm trying to duplicate my mysql tables for hsqldb in order to run some unit tests in my JPA / Hibernate project.

There are only two tables at the moment, but I can't get neither created in hsqldb. I used the example code from Spring documentation to run a schema.sql script before the test cases:

db = new EmbeddedDatabaseBuilder().addDefaultScripts().build();

But it always fails with "Unexpected token" exceptions with the token ranging from "DATABASE" to "(".

Is there a straight forward way of converting the mysql dump into something that hsqldb would understand? Or should I populate the test database some other way?

Upvotes: 1

Views: 2805

Answers (1)

L. G.
L. G.

Reputation: 9761

I worked many years with HSQL and MySQL database and there's no tool that I know that converts a MySQL dump into a hsqldb script. I see two solutions here:

  1. Make a script or a program that converts MySQL dumps to hsqldb script. You can follow the list of steps to do in this post: How to load mysql dump to hsqldb database? Use BOTH responses https://stackoverflow.com/a/3813164/891479 and https://stackoverflow.com/a/7791340/891479 as the first one is not complete.
  2. Make a small program that connects to both DB, load your MySQL tables into objects and fill your hsqldb.

We always used the first solution, it's probably the easiest one.

Upvotes: 2

Related Questions