Skip to content

AlphaHinex/mysql2h2-converter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mysql2h2-converter

A MySQL to H2 SQL conversion library written in Java.

Parse a MySQL dump and convert it to H2 statements either as an embedded library or as a standalone tool.

Next steps can include:

Other ideas:

Building

mvn clean package will generate the SQL parser and build an executable JAR.

enhance branch

Extend the parser to support more statements, see BasicTest and ConverterTest diff for details.

Since last commit of andrewparmet/mysql2h2-converter is 2018, change this library's pom to a new group and new version, and you can use the new one from JitPack.

Gradle example:

Step 1. Add the JitPack repository to your build file:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Step 2. Add the dependency:

dependencies {
    implementation 'com.github.alphahinex:mysql2h2-converter:0.3.1'
}

Usage

As a library:

private static void convertAndCreate(Statement stmt, String sqlDump) throws SQLException, ParseException {
    List<SQLStatement> stmts = SQLUtils.parseStatements(sqlDump, DbType.mysql, SQLParserFeature.MySQLSupportStandardComment);
    
    stmt.execute(SQLUtils.toSQLString(stmts, DbType.h2));
}

On the command line, after mvn package of course:

$ java -jar target/mysql2h2-converter-tool-0.3.1.jar demos/disconf-mysql.sql > disconf-h2.sql

License

This code is provided under the MIT license.

About

A MySQL to H2 SQL conversion library written in Java

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%