Applies to
- Liquibase Pro
- Liquibase Open Source (Community)
Conditions
- Involves JAR files stored outside the lib folder and manually setting the
classpath
property in the properties file.
Issue Summary
When storing JAR files outside the lib folder and pointing to them using the classpath property, Liquibase throws an error that the driver class was not specified, even though the URL should determine it.
With some databases, this setup can lead to Liquibase failing to create the DATABASECHANGELOG
table correctly and throw errors when running Liquibase commands, failing to find the default schema, and using unsupported SQL data types such as DATETIME
.
Error Message
Error 1: Missing Driver Class
Driver class was not specified and could not be determined from the url
Error 2: Unsupported SQL Data Type
ERROR: Exception Primary Class: ErrorException
ERROR: Exception Primary Reason: [Databricks][JDBCDriver](500051) ERROR processing query/statement. Error Code: 0, SQL state: 0A000, Query: CREATE TAB***, Error message from Server: org.apache.hive.service.cli.HiveSQLException: Error running query: [UNSUPPORTED_DATATYPE] org.apache.spark.sql.catalyst.parser.ParseException:
[UNSUPPORTED_DATATYPE] Unsupported data type "DATETIME". SQLSTATE: 0A000 (line 1, pos 133)
== SQL ==
CREATE TABLE DATABASECHANGELOG (ID VARCHAR(255) NOT NULL, AUTHOR VARCHAR(255) NOT NULL, FILENAME VARCHAR(255) NOT NULL, DATEEXECUTED datetime NOT NULL, ORDEREXECUTED INT NOT NULL, EXECTYPE VARCHAR(10) NOT NULL, MD5SUM VARCHAR(35), DESCRIPTION VARCHAR(255), COMMENTS VARCHAR(255), TAG VARCHAR(255), LIQUIBASE VARCHAR(20), CONTEXTS VARCHAR(255), LABELS VARCHAR(255), DEPLOYMENT_ID VARCHAR(10))
Root Cause
The issue arises because Liquibase cannot determine the driver class, which is required to generate correct SQL, from the provided JDBC URL when the required JAR files are stored outside the lib
folder. Normally, the driver class should be identified automatically, but this behavior breaks when using the classpath
property to point to external JAR files.
This is a confirmed product issue, and the fix is in progress.
Resolution
Workaround #1: Use a liquibase_libs
Directory in the Project
The recommended solution is to create a liquibase_libs
directory within the local working project directory and store the necessary JAR files there.
In this setup, you can remove the classpath
and driver
properties from the properties file, and Liquibase should automatically detect and use the appropriate JAR files.
Workaround #2: Manually Specify the Driver Class
An alternative solution is explicitly providing the driver class name in the properties file.
Add the following line to your liquibase.properties
file:
You can find the full list of driver class names in our documentation, Liquibase Database Tutorials.
Note: This workaround only resolves the driver class issue. To resolve the issue where the DATABASECHANGELOG table is not created when the JAR files are stored and referenced in this way, you'll need to use Workaround #1: Use a liquibase_libs Directory in the Project.
Comments
0 comments
Article is closed for comments.