7/15/2016

In memory MySQL for java | Embedded MySQL for java unit testing

Mainly used the idea from:
http://blog.palominolabs.com/2011/10/03/embedded-mysql-on-java-with-connectormxj-and-64-bit-linux/
And
https://github.com/airlift/testing-mysql-server

The idea is to use mysql-connector-mxj, but the development has been discontinued. Therefore the newest version that came with it is Mysql 5.5.9. That's included in mysql-connector-mxj-db-files.

That's too old and I want to use a newer version: 5.7.5.

The goal here is therefore to build the new mysql-connector-mxj-db-files jar file to include the new Mysql version.

Here is what I did:

1. Download the newer version MySQL to: ~/Downloads/mysql-5-7-5/mysql-5.7.5-m15-linux-glibc2.5-x86_64

2. Run the command:
bin/mysql_install_db --insecure  --user=mysql --datadir=/tmp/dbfiles/5-7-5/data --lc-messages-dir=./share/

cd /tmp/dbfiles/5-7-5/data
jar -cf ../data_dir.jar *

This step generates the data folder to /tmp/dbfiles/5-7-5/data. Then I create the data_dir.jar file. The data_dir.jar file should be included in the mysql-connector-mxj-db-files jar.

Another command to run:
jar -cf /tmp/dbfiles/5-7-5/share_dir.jar share/

The share_dir.jar should also be included in the mysql-connector-mxj-db-files jar.

3. Create the mysql-connector-mxj-db-files.jar with newer MySQL version.

Unzip the original mysql-connector-mxj-db-files.jar file. Copy the mysql, mysqld file, data_dir.jar, share_dir.jar to appropriate locations.

Run another jar -cf bla bla command to create the final mysql-connector-mxj-db-files.jar.

No comments: