Unexpected error running Liquibase: liquibase.exception.DatabaseException

Hello, Greetings. I am a novice to Liquibase and working on getting “Liquibase Fundamentals Certification.” Please pardon me for my long winded post. I have successfully installed Liquibase on my MacBook Air and able to run “liquibase --help” successfully. In the “example” folder under “SQL” subfolder, there is a liquibase.properties file that system is using to launch h2 browser based H2 Console. In the training section, Module 3, there is an activity " Activity 2: Creating Changelogs and Changesets with SQL." Since I do not have any database on my machine, I am hoping to connect to the example H2 database provided by Liquibase installation. The liquibase.properties file has the following content:

Enter the Target database ‘url’ information

url=jdbc:h2:tcp://localhost:9090/mem:dev

Enter the username for your Target database.

username: dbuser

Enter the password for your Target database.

password: letmein

But when I run the command “liquibase --changeLogFile=dbchangelog.h2.sql generateChangeLog”, I am getting the following error. Is there a training database I can connect provided by Liquibase as a part of the certification course? Any help is greatly appreciated. Thank you in advance for your help.

Liquibase Community 4.3.2 by Datical
####################################################

####################################################

Starting Liquibase at 23:48:26 (version 4.3.2 #44 built at 2021-03-23 14:01+0000)

Unexpected error running Liquibase: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: Connection could not be created to jdbc:h2:tcp://localhost:9090/mem:dev with driver org.h2.Driver. Connection is broken: “java.net.ConnectException: Connection refused: localhost:9090” [90067-200]

For more information, please use the --logLevel flag

Hi @dearraja

From the error it seems Liquibase is not able to form Database connection. You might have missed starting the H2 database. Could you try running the start-h2 script before executing generateChangelog statement?

You will find the start-h2 script inside examples directory itself.

Please let us know if you face any issues.

Thanks!
Rakhi Agrawal

Dear @rakhi , this is awesome. Thank you for your suggestion, which worked like a charm. Appreciate your help.

1 Like