简体   繁体   English

在春季启动应用程序中连接到Azure MS SQL Server

[英]connect to azure ms sqlserver in spring boot application

I'm trying to connect to the azure ms sqlserver database. 我正在尝试连接到蔚蓝ms sqlserver数据库。 I have setup these properties in the application.properties file, but I get exceptions, connection timed out. 我已经在application.properties文件中设置了这些属性,但是出现异常,连接超时。

spring.datasource.url=jdbc:jtds:sqlserver://xxxserver.database.windows.net:port;DatabaseName=xxxdb;user=xxxadmin@xxxserver;password=passwd;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;
spring.datasource.username=xxxadmin@xxxserver
spring.datasource.password=passwd
spring.datasource.driver-class-name=net.sourceforge.jtds.jdbc.Driver

spring.jpa.hibernate.ddl-auto=update

I get this exception: 我得到这个例外:

2016-02-16 23:36:46.645 ERROR 7840 --- [           main] o.a.tomcat.jdbc.pool.ConnectionPool      : Unable to create initial connections of pool.

java.sql.SQLException: Login timed out.
    at net.sourceforge.jtds.jdbc.JtdsConnection.<init>(JtdsConnection.java:433) ~[jtds-1.3.1.jar:1.3.1]
    at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:184) ~[jtds-1.3.1.jar:1.3.1]
    at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:307) ~[tomcat-jdbc-8.0.30.jar:na]
    at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:200) ~[tomcat-jdbc-8.0.30.jar:na]
    at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:708) [tomcat-jdbc-8.0.30.jar:na]
    at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:642) [tomcat-jdbc-8.0.30.jar:na]
    at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:464) [tomcat-jdbc-8.0.30.jar:na]

In the past the jtds driver had problems with azure sql due to the driver having problems negotiating the SSL encryption handshake. 过去,由于jtds驱动程序在协商SSL加密握手时遇到问题,因此azure sql出现问题。 The recommended driver is the Microsoft one. 推荐的驱动程序是Microsoft。

more info here: https://azure.microsoft.com/nl-nl/documentation/articles/sql-database-develop-java-simple-windows/ 此处提供更多信息: https : //azure.microsoft.com/nl-nl/documentation/articles/sql-database-develop-java-simple-windows/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM