Saturday, February 1, 2014

Working with H2, Gradle, H2Sharp, IntelliJ Idea and Flyway - Experience

1. In gradle with flyway, the H2 database doesn't work at version 1. It doesn't throw any error, it says migration is successful. But it doesn't create tables in the database. So we should start from the version 2 sql files.
Example: V1__TestDatabaseSchema.sql file doesn't work.
V2__TestDatabaseSchema.sql file works. Version number matters

2. There must be double hyphen in the filename after the version number (V2, V1 and etc).

3. I faced "Connection refused: connect" in IntelliJ.
So I tried various options like enabling IPV4, windows hot fix, installing ISA Client, restarting machine, switched java language level in IntelliJ, disabled firewall and other options mentioned in the internet. Finally I added http proxy in the IntelliJ Idea. That worked. In my office network I have Automatic configuration script enabled.

I posted my solution to the public forum http://stackoverflow.com/questions/12701347/unable-to-import-maven-project-into-intellij-idea/20758527#20758527.


So I copy pasted the proxy settings as below in IntelliJ Idea.
I was unable to download maven project from IntelliJ. When I typed the library names, it didn't give me any result. The above solution fixed this problem too. 4. When connecting H2 database with other tools in file mode, the same database should not be open in Web UI. The reason is, in file mode, multiple JVM deamons cannot access the database at the same time, it throws error. The file will be locked by one JVM deamon process.
Example: jdbc:h2:file:F:\folderName\fileName;

5. The order for running gradle script to migrate H2 via flyway is
flywayClean, flywayInit, flywayMigrate
So when there is any error in the migrate, after making changes re-run from flywayClean. flywayClean drops all tables.

6. The Sql Server Mode is mandatory when connecting to the H2 Web Console. Otherwise the query for sql server won't compile. It will succeed when running gradle scripts, but won't yeild result.

7. There are two version of H2 Sharp available in the internet.
    a. Git https://code.google.com/p/h2sharp/
    b. Google code https://github.com/Remo/h2sharp/tree/master/Dlls
Code downloaded from google code didn't work, I faced compile errors. Only git version worked for me.

8. Be careful about datetime field when using H2+H2Sharp in a .net project. It didn't work for me.

No comments:

Post a Comment