Hey there,
just stumbeled across this tool and tried to give it a try but had some obsticales to overcome:
To be able to execute the released JAR I had to lookup required dependencys in the jars manifest first and provide those jars alongside the main jar in /lib. No big deal, just wanted to point that one out (maybe add it to the readme?).
Required libs which needs to be provided at runtime seem to be:
- commons-cli-1.4.jar
- commons-io-2.8.0.jar
- commons-lang3-3.3.2.jar
As soon as those are present the Tool runs fine (UI shows up and/or you can use the cli).
But after that I noticed that no matter what i try the tool fails right after the export step when it tries to create the new h2 Database from the generated .sql script.
It looks like the jdbc paths are build wrong when running on a Windows maschine: (the problem here is the Drive letter followed by the ':'):
INFORMATION: Wrote H2-1.4.200 database to script: D:\Test\TestH2Database.sql
Exception in thread "main" java.lang.Exception: Failed to migrate the database.
at com.manticore.h2.H2MigrationTool.main(H2MigrationTool.java:1149)
Caused by: java.lang.Exception: Failed to created new H2-2.1.210 database: D:\Test\TestH2Database
at com.manticore.h2.H2MigrationTool.migrate(H2MigrationTool.java:922)
at com.manticore.h2.H2MigrationTool.main(H2MigrationTool.java:1142)
Caused by: org.h2.jdbc.JdbcSQLNonTransientException: Allgemeiner Fehler: "java.nio.file.InvalidPathException: Illegal character [:] in path at index 3: //D:/Test/TestH2Database.210null"
General error: "java.nio.file.InvalidPathException: Illegal character [:] in path at index 3: //D:/Test/TestH2Database.210null" [50000-210]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:573)
at org.h2.message.DbException.getJdbcSQLException(DbException.java:496)
at org.h2.message.DbException.get(DbException.java:216)
at org.h2.message.DbException.convert(DbException.java:414)
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:340)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:122)
at org.h2.Driver.connect(Driver.java:59)
at com.manticore.h2.H2MigrationTool.createFromScript(H2MigrationTool.java:799)
at com.manticore.h2.H2MigrationTool.migrate(H2MigrationTool.java:913)
... 1 more
Caused by: java.nio.file.InvalidPathException: Illegal character [:] in path at index 3: //D:/Test/TestH2Database.210null
at java.base/sun.nio.fs.WindowsPathParser.nextSlash(WindowsPathParser.java:212)
at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:111)
at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92)
at java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:229)
at java.base/java.nio.file.Path.of(Path.java:147)
at java.base/java.nio.file.Paths.get(Paths.java:69)
at org.h2.store.fs.disk.FilePathDisk.isAbsolute(FilePathDisk.java:308)
at org.h2.store.fs.FileUtils.isAbsolute(FileUtils.java:144)
at org.h2.engine.ConnectionInfo.getName(ConnectionInfo.java:457)
at org.h2.engine.Engine.openSession(Engine.java:49)
at org.h2.engine.Engine.openSession(Engine.java:222)
at org.h2.engine.Engine.createSession(Engine.java:201)
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:338)
... 5 more
So I took a quick look into the code and found two relevant occurences of "driver.connect(...)" in H2MigrationTool.java that look like this:
connection = driver.connect(
"jdbc:h2://" + databaseFileName + ";ACCESS_MODE_DATA=r" + connectionParameters,
properties);
In order to work properly with Windows filepaths something like this should work (using such connection strings in my own tool as well):
connection = driver.connect(
"jdbc:h2:file:" + databaseFileName + ";ACCESS_MODE_DATA=r" + connectionParameters,
properties);
Bringing me to the next point:
I tried to change those code parts accordingly and rebuild it locally on my machine using the provided build.xml file but can't get it to build either because of some absolute paths in the whole build xmls pointing to specific local paths and missing ClassPath configurations (those libs again mentioned above).
All in all very nice idea but does not seem to work poperly (yet) on Windows maschines unless I overlooked something.