diff --git a/src/main/java/liquibase/ext/cassandra/database/CassandraDatabase.java b/src/main/java/liquibase/ext/cassandra/database/CassandraDatabase.java index 3094c0fd..af5e195b 100644 --- a/src/main/java/liquibase/ext/cassandra/database/CassandraDatabase.java +++ b/src/main/java/liquibase/ext/cassandra/database/CassandraDatabase.java @@ -59,7 +59,10 @@ public boolean isCorrectDatabaseImplementation(DatabaseConnection conn) throws D @Override public String getDefaultDriver(String url) { - return "com.simba.cassandra.jdbc42.Driver"; + if (String.valueOf(url).startsWith("jdbc:cassandra:")) { + return "com.simba.cassandra.jdbc42.Driver"; + } + return null; } @Override diff --git a/src/main/java/liquibase/ext/cassandra/sqlgenerator/TagDatabaseGeneratorCassandra.java b/src/main/java/liquibase/ext/cassandra/sqlgenerator/TagDatabaseGeneratorCassandra.java index e3bfdd38..da89bc14 100644 --- a/src/main/java/liquibase/ext/cassandra/sqlgenerator/TagDatabaseGeneratorCassandra.java +++ b/src/main/java/liquibase/ext/cassandra/sqlgenerator/TagDatabaseGeneratorCassandra.java @@ -15,6 +15,7 @@ import liquibase.database.Database; import liquibase.database.ObjectQuotingStrategy; import liquibase.datatype.DataTypeFactory; +import liquibase.exception.DatabaseException; import liquibase.ext.cassandra.database.CassandraDatabase; import liquibase.sql.Sql; import liquibase.sql.UnparsedSql; @@ -79,13 +80,7 @@ public Sql[] generateSql(TagDatabaseStatement statement, Database database, SqlG - } catch (SQLException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - return super.generateSql(statement, database, sqlGeneratorChain); - } catch (ClassNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + } catch (SQLException | DatabaseException e) { return super.generateSql(statement, database, sqlGeneratorChain); } finally { database.setObjectQuotingStrategy(currentStrategy); diff --git a/src/test/groovy/liquibase/ext/cassandra/database/CassandraDatabaseTest.groovy b/src/test/groovy/liquibase/ext/cassandra/database/CassandraDatabaseTest.groovy index e0f63f74..3a0f3dc2 100644 --- a/src/test/groovy/liquibase/ext/cassandra/database/CassandraDatabaseTest.groovy +++ b/src/test/groovy/liquibase/ext/cassandra/database/CassandraDatabaseTest.groovy @@ -9,4 +9,11 @@ class CassandraDatabaseTest extends Specification { new CassandraDatabase().getShortName() == "cassandra" } + def getDefaultDriver() { + expect: + new CassandraDatabase().getDefaultDriver(null) == null + new CassandraDatabase().getDefaultDriver("jdbc:mysql://localhost") == null + new CassandraDatabase().getDefaultDriver("jdbc:cassandra://localhost") != null + } + }