0
votes

I have a simple application in java spring, but I am not able to configure the connection to the local sql server database, which has authentication integrated with windows.

My properties

    spring.datasource.url=jdbc:sqlserver://localhost;databaseName=mydatabase
    spring.integratedSecurity=true
    spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
    spring.jpa.hibernate.dialect=org.hibernate.dialect.SQLServer2012Dialect
    spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
    spring.datasource.testOnBorrow=false
    spring.datasource.validationQuery=SELECT 1

My database configuration

enter image description here

com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 1433 has failed. Error: "Connection refused: connect. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.

Thanks.

1

1 Answers

0
votes

You will need to add integratedSecurity=true in your spring.datasource.url.

something like this in your application.properties will do,

spring.datasource.url=jdbc:sqlserver://localhost;databaseName=mydatabase;integratedSecurity=true

see these link for more information :

https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/sql/authentication-in-sql-server

https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/connection-string-syntax