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?
当我使用 setPassword 方法设置密码时,此问题得到解决。
dataSource.setPassword(password);
For me, I had to update the db.url from this:
jdbc:sqlserver:myservername.awsaddress.us-east-1.rds.amazonaws.com:1433;databaseName=exdb
to this:
jdbc:sqlserver://myservername.awsaddress.us-east-1.rds.amazonaws.com:1433;databaseName=exdb
I forgot the double forward slash.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.