Reputation: 858
I am trying to setup liquibase for db deployment to MS SQL Server 2014. When I try to run an update (using command line), I get the following error message:
Unexpected error running Liquibase: liquibase.exception.DatabaseException: Connection could not be created to "jdbc:sqlserver://myserver:1234;databaseName=mydb" with driver com.microsoft.sqlserver.jdbc.SQLServerDriver. Possibly the wrong driver for the given database URL
My properties file is:
classpath=D:\\Tools\\Liquibase\\Microsoft JDBC Driver 6.2 for SQL Server\\sqljdbc_6.2\\enu\\mssql-jdbc-6.2.2.jre8.jar
driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
url="jdbc:sqlserver://myserver:1234;databaseName=mydb"
username=MyUserName
password=SomePassword
changeLogFile=D:\\Tools\\Liquibase\\Test.sql
The liquibase batch file is being ran in the following environment:
Windows Server 2012
Java 1.8.0_31
I also tested the connection by using Microsoft's JDBC sample code. I added the mssql-jdbc-6.2.2.jre8.jar to my project and successfully ran a query using the same url, username, databaseName, and password from the properties file.
String connectionUrl = "jdbc:sqlserver://myserver:1234;databaseName=mydb;user=MyUserName;password=SomePassword";
I am certain that I have the right driver and that a connection can be established. However, I cannot figure out what is wrong.
Debug Log:
SEVERE 3/1/18 1:54 PM: liquibase: liquibase.exception.DatabaseException: Connection could not be created to "jdbc:sqlserver://myserver:2431;databaseName=mydb;" with driver com.microsoft.sqlserver.jdbc.SQLServerDriver.
Possibly the wrong driver for the given database URL
liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: Connection could not be created to "jdbc:sqlserver://myserver:2431;databaseName=mydb;" with driver com.microsoft.sqlserver.jdbc.SQLServerDriver.
Possibly the wrong driver for the given database URL
at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:127)
at liquibase.integration.commandline.Main.doMigration(Main.java:958)
at liquibase.integration.commandline.Main.run(Main.java:188)
at liquibase.integration.commandline.Main.main(Main.java:103)
Caused by: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: Connection could not be created to "jdbc:sqlserver://myserver:2431;databaseName=mydb;" with driver com.microsoft.sqlserver.jdbc.SQLServerDriver. Possibly the wrong driver for the given database URL
at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:247)
at liquibase.database.DatabaseFactory.openDatabase(DatabaseFactory.java:151)
at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:85)
... 3 more
Caused by: liquibase.exception.DatabaseException: Connection could not be created to "jdbc:sqlserver://myserver:2431;databaseName=mydb;" with driver com.microsoft.sqlserver.jdbc.SQLServerDriver. Possibly the wrong driver for the given database URL
at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:242)
... 5 more
RESOLVED:
classpath=D:\\Tools\\Liquibase\\Microsoft JDBC Driver 6.2 for SQL Server\\sqljdbc_6.2\\enu\\mssql-jdbc-6.2.2.jre8.jar
driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
url=jdbc:sqlserver://myserver:1234;databaseName=mydb
username=MyUserName
password=SomePassword
changeLogFile=D:\\Tools\\Liquibase\\Test.sql
Upvotes: 4
Views: 13340
Reputation: 858
I found the problem. The problem is the quotes (") around the url in the properties file. By removing the quotes, liquidbase ran fine..... a lot of brain hurt right now.
Upvotes: 10