I am using below dependencies.
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>7.4.1.jre8</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>adal4j</artifactId>
<version>1.6.4</version>
</dependency>
When I form the connection url like below.
String connectionUrl = jdbcURL + ";databaseName=" + databaseName + ";user=" + userName + ";password="
+ password
+ ";encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;"
+ "loginTimeout=30;authentication=ActiveDirectoryPassword";
I am getting error like:
' 'java.lang.RuntimeException: Driver com.microsoft.sqlserver.jdbc.SQLServerDriver claims to not accept jdbcUrl,'
When I enclosed the password in curly braces like below, I am able to successfully connect to Azure sql server.
String connectionUrl = jdbcURL + ";databaseName=" + databaseName + ";user=" + userName + ";password={"
+ password + "}"
+ ";encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;"
+ "loginTimeout=30;authentication=ActiveDirectoryPassword";
Just FYI, password has one open curly brace {, is it causing any trouble? is it mandatory to enclose the password string in curly braces?
This problem is resolved when I set the password using setPassword method.
dataSource.setPassword(password);