diff --git a/liquibase-core/src/main/java/liquibase/database/core/PostgresDatabase.java b/liquibase-core/src/main/java/liquibase/database/core/PostgresDatabase.java
index <HASH>..<HASH> 100644
--- a/liquibase-core/src/main/java/liquibase/database/core/PostgresDatabase.java
+++ b/liquibase-core/src/main/java/liquibase/database/core/PostgresDatabase.java
@@ -41,7 +41,9 @@ public class PostgresDatabase extends AbstractJdbcDatabase {
     @Override
     public void setConnection(DatabaseConnection conn) {
         try {
-            reservedWords.addAll(Arrays.asList(((JdbcConnection) conn).getMetaData().getSQLKeywords().toUpperCase().split(",\\s*")));
+            if (conn instanceof JdbcConnection) {
+                reservedWords.addAll(Arrays.asList(((JdbcConnection) conn).getMetaData().getSQLKeywords().toUpperCase().split(",\\s*")));
+            }
         } catch (Exception e) {
             LogFactory.getLogger().warning("Cannot retrieve reserved words", e);
         }
Check connection type to work better with tests with mock connection