0

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 Answer 1

0

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://learn.microsoft.com/en-us/dotnet/framework/data/adonet/sql/authentication-in-sql-server

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

Sign up to request clarification or add additional context in comments.

1 Comment

(1) find sqljdbc_auth.dll file from microsoft jdbc driver installation folder, one you installed previously from the jdbc driver link. The path would be something like: <installation directory>\sqljdbc_<version>\<language>\auth\ (2) copy sqljdbc_auth.dll file to your JAVA_HOME/bin folder. (3) Restart your sql server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.