I installed Liquibase CLI using snap package manager on Kubuntu.
Invoking the following command results in a
liquibase calculateChecksum 2022-01-06-test.sql::1::bobby.tables --changeLogFile 2022-01-06-test.sql
--url jdbc:mysql://localhost:3306 --username root --password password
--driver com.mysql.jdbc.Driver --classpath ~/.m2/repository/mysql/mysql-connector-java/8.0.21/mysql-connector-java-8.0.21.jar
Results in a stacktrace (DEBUG)
liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: java.lang.RuntimeException: Cannot find database driver: com.mysql.jdbc.Driver
at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:131)
at liquibase.integration.commandline.Main.doMigration(Main.java:1408)
at liquibase.integration.commandline.Main$1.lambda$run$0(Main.java:361)
at liquibase.Scope.lambda$child$0(Scope.java:160)
at liquibase.Scope.child(Scope.java:169)
at liquibase.Scope.child(Scope.java:159)
at liquibase.Scope.child(Scope.java:138)
at liquibase.Scope.child(Scope.java:222)
at liquibase.Scope.child(Scope.java:226)
at liquibase.integration.commandline.Main$1.run(Main.java:360)
at liquibase.integration.commandline.Main$1.run(Main.java:193)
at liquibase.Scope.child(Scope.java:169)
at liquibase.Scope.child(Scope.java:145)
at liquibase.integration.commandline.Main.run(Main.java:193)
at liquibase.integration.commandline.Main.main(Main.java:156)
Caused by: liquibase.exception.DatabaseException: java.lang.RuntimeException: Cannot find database driver: com.mysql.jdbc.Driver
at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:250)
at liquibase.database.DatabaseFactory.openDatabase(DatabaseFactory.java:140)
at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:96)
... 14 more
Caused by: java.lang.RuntimeException: Cannot find database driver: com.mysql.jdbc.Driver
at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:192)
... 16 more
I am not using a liquibase.properties file as I just want to calculate an md5 hash sum, so I can compare it with a different md5 value.
Do I need to put the mysql.jar where the liquibase binary is?
If so, where does it live as a snap package?
It turns out Snap doesn't allow access to .m2 folder in the user's $HOME directory (which is madness/stupidity).
Therefore you need to give the liquibase snap access to the .m2 folder
To see where Liquibase can access:
snap connections liquibase
Which will print out this:
Interface Plug Slot Notes
home liquibase:home :home -
network liquibase:network :network -
personal-files liquibase:dot-m2-repository - -
removable-media liquibase:removable-media - -
Then run the following command to give Liquibase access to .m2
folder
sudo snap connect liquibase:dot-m2-repository
This should allow Liquibase to function properly.
Why this is not documented anywhere? I do not know...