我正在尝试连接到azure ms sqlserver数据库。我在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
我得到了这个例外:
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]
答案 0 :(得分:0)
过去,由于驱动程序在协商SSL加密握手时遇到问题,因此jtds驱动程序存在azure sql问题。 推荐的驱动程序是Microsoft。
更多信息: https://azure.microsoft.com/nl-nl/documentation/articles/sql-database-develop-java-simple-windows/