Skip to content

Commit

Permalink
Update connection to more robustly parse url and edit it
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyAustinDavis committed May 10, 2024
1 parent 6be6792 commit 1513901
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ public void open(String url, Driver driverObject, Properties driverProperties) t
driverProperties.setProperty("UserAgentEntry", "Liquibase");
// Set UserAgent to specify to Databricks that liquibase is the tool running these commands
// Set EnableArrow because the arrow results break everything. And the JDBC release notes say to just disable it.
String updatedUrl = url + "UserAgentEntry=Liquibase;EnableArrow=0";
this.openConn(updatedUrl, driverObject, driverProperties);
//String updatedUrl = url + "UserAgentEntry=Liquibase;EnableArrow=0";
// This is done in getConnectionUrl()

this.openConn(url, driverObject, driverProperties);
}

public void openConn(String url, Driver driverObject, Properties driverProperties) throws DatabaseException {
Expand Down Expand Up @@ -143,8 +145,18 @@ public int getDatabaseMinorVersion() throws DatabaseException {
/////////////////////////////////////////////////// copy from parent ///////////////////////////////////////////////////
@Override
protected String getConnectionUrl() throws SQLException {

String rawUrl = con.getMetaData().getURL();
String updatedUrl = rawUrl + "UserAgentEntry=Liquibase;EnableArrow=0";
// Check for ; characters
String updatedUrl;

if (rawUrl.charAt(rawUrl.length() - 1) == ';') {
updatedUrl = rawUrl + "UserAgentEntry=Liquibase;EnableArrow=0;";
}
else {
updatedUrl = rawUrl + ";UserAgentEntry=Liquibase;EnableArrow=0;";

}
return updatedUrl;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ protected String getConnectionSchemaName() {

try {
String foundSchema = parseUrlForSchema(connection.getURL());
System.out.println("SCHEMA IDENTIFIED: " + foundSchema);
Scope.getCurrentScope().getLog(getClass()).info("SCHEMA IDENTIFIED: " + foundSchema);

return foundSchema;
} catch (Exception e) {
Expand Down Expand Up @@ -242,7 +242,7 @@ protected String getConnectionCatalogName() {

try {
String foundCatalog = parseUrlForCatalog(connection.getURL());
System.out.println("CATALOG IDENTIFIED: " + foundCatalog);
Scope.getCurrentScope().getLog(getClass()).info("CATALOG IDENTIFIED: " + foundCatalog);

return foundCatalog;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"liquibase.structure.core.Schema": [
{
"schema": {
"name": "liquibase_test"
"name": "liquibase_harness_test_ds"
}
}
]
Expand Down

0 comments on commit 1513901

Please sign in to comment.