Im working on Java Spring Boot application, and have a problem with connection to database via JPA. JPA cannot connect to my db. I tried many url configurations, but connection failed and such exception shows:
java.lang.RuntimeException: Driver com.microsoft.sqlserver.jdbc.SQLServerDriver claims to not accept jdbcUrl
Im using Microsoft SQL Server localdb. Here is my application.properties configuration
spring.application.name=Two4H
server.port=8080
spring.datasource.url=jdbc:jtds:sqlserver://.\\MSSQLLocalDB\\Two4H;integratedSecurity=true;TrustServerCertificate=true
spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.SQLServerDialect
And this is my DB connection in IntelliJ which i would like to connect to my application:
I fixed this problem. At first I use SQL Server 2022 Configuration Manager to set new local SQL Server and configure its TCP/IP protocol. Then I simply change URL in Spring Boot's application.properties to:
spring.datasource.url=jdbc:sqlserver://localhost:1433;database=Two4H;integratedSecurity=true;TrustServerCertificate=true
Here's a good article I found
https://springframework.guru/configuring-spring-boot-for-microsoft-sql-server