我正在开发 Java Spring Boot 应用程序,并且在通过 JPA 连接到数据库时遇到问题。 JPA 无法连接到我的数据库。我尝试了很多 url 配置,但连接失败并且出现这样的异常:
java.lang.RuntimeException: Driver com.microsoft.sqlserver.jdbc.SQLServerDriver claims to not accept jdbcUrl
我正在使用 Microsoft SQL Server localdb。这是我的 application.properties 配置
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
对于 SQL Server URL 和驱动程序类应该是
spring.datasource.url=jdbc:sqlserver://MSSQLLocalDB:1433;database=Two4H;integratedSecurity=true;TrustServerCertificate=true
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver