Skip to content

Commit

Permalink
DAT-18897: merged main branch changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Mykhailo Savchenko committed Nov 14, 2024
2 parents e977fa9 + ce73780 commit 63c553b
Showing 1 changed file with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
import liquibase.structure.DatabaseObject;
import liquibase.structure.core.Catalog;
import liquibase.structure.core.Schema;
import org.apache.commons.lang3.StringUtils;
import lombok.Setter;

import java.math.BigInteger;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;


Expand Down Expand Up @@ -363,4 +363,23 @@ public void setConnection(DatabaseConnection conn) {
super.setConnection(dbConn);
}

@Override
public void checkDatabaseConnection() throws DatabaseException {
DatabricksConnection connection = (DatabricksConnection) getConnection();
try {
String catalogName = getConnectionCatalogName();
String schemaName = getConnectionSchemaName();
ResultSet schemasAlikeUsed = connection.getMetaData().getSchemas(catalogName, schemaName);
while (schemasAlikeUsed.next()) {
if (schemasAlikeUsed.getString(1).equals(schemaName)) {
return;
}
}
throw new DatabaseException(String.format("Please specify existing schema and catalog in connection url. " +
"Current connection points to '%s.%s'", catalogName, schemaName));
} catch (SQLException e) {
Scope.getCurrentScope().getLog(getClass()).info("Error checking database connection", e);
}
}

}

0 comments on commit 63c553b

Please sign in to comment.