Is Java required to install with node js project, Mysql

const Liquibase = require(“node-liquibase”).Liquibase;
const MYSQL_DEFAULT_CONFIG = require(“node-liquibase”).MYSQL_DEFAULT_CONFIG;

const myConfig = {
…MYSQL_DEFAULT_CONFIG,
changeLogFile: “./liquibase-changelog.xml”,
url: “jdbc:mysql://localhost:3306/ams_dev”,
username: “root”,
password: “password”,
};

const instance = new Liquibase(myConfig);

instance.update();

Getting below error.
Unexpected error running Liquibase: java.lang.RuntimeException: Cannot find database driver: com.mysql.jdbc.Driver

Hey @Anilsar :smiley:,

Depending on which version of node-liquibase is being used here, the MYSQL_DEFAULT_CONFIG may not be available anymore. In order for node-liquibase (and the underlying liquibase process) to work properly, liquibase will need to have the appropriate database driver made known to it.

Here’s a link to the docs for liquibase that touches on how liquibase uses the database drivers, and how to “load them into” liquibase. This is nice information to have for additional context on the root of the issue we’re seeing here.

One “quick” solution to get you up and running would be to provide the driver to liquibase through node-liquibase like so:

const Liquibase = require("node-liquibase").Liquibase;
// const MYSQL_DEFAULT_CONFIG = require("node-liquibase").MYSQL_DEFAULT_CONFIG;

const myConfig = {
  // ...MYSQL_DEFAULT_CONFIG, // NOTE: Depending on `node-liquibase` version, this may not work :(
  changeLogFile: "./liquibase-changelog.xml",
  url: "jdbc:mysql://localhost:3306/ams_dev",
  username: "root",
  password: "password",
  classPath: "/the/path/to/the/locally/stored/mysql-connector-java-8.0.25.jar",
};

const instance = new Liquibase(myConfig);

instance.update();

I’m curious if this solution will get you back up and running! Let me know how it goes! :rocket:

Hey , Thanks for reply, we are using below versions. {
“dependencies”: {
“mysql”: “^2.18.1”,
“node-liquibase”: “^4.1.1”
},
“scripts”: {
“build”: “npm run build”
}
}

But still it is saying Error below.
‘“java”’ is not recognized as an internal or external command,
operable program or batch file.

Please suggest which version of liquibase will not ask java to be installed