Cannot load driver class: com.microsoft.jdbc.sqlserver.SQLServerDriver

后端 未结 2 1605
慢半拍i
慢半拍i 2020-12-20 17:02

I am getting an exception while running my spring boot application, it say unable to create bean of datasource and caused of this exception is that it unable to detect my Dr

相关标签:
2条回答
  • 2020-12-20 17:46

    Is the jar present on your system? You are forcing maven to get the dependency from the system and if it is not on that path maven will fail. Can you replace the tag with these :

    <dependency>
        <groupId>com.microsoft</groupId>
        <artifactId>sqljdbc4</artifactId>
        <version>3.0</version>
    </dependency>
    

    Source: https://mvnrepository.com/artifact/com.microsoft/sqljdbc4/3.0

    0 讨论(0)
  • 2020-12-20 17:55

    You are trying to load the wrong driver. The driver with name com.microsoft.jdbc.sqlserver.SQLServerDriver is from the very old SQL Server 2000 JDBC driver.

    In the SQL Server 2005 JDBC driver, Microsoft changed this to com.microsoft.sqlserver.jdbc.SQLServerDriver (note the switch of order between sqlserver and jdbc.

    Side note: you are using an old version of the driver. Microsoft has open sourced the SQL Server JDBC driver and it is available on maven as:

    <dependency>
        <groupId>com.microsoft.sqlserver</groupId>
        <artifactId>mssql-jdbc</artifactId>
        <version>6.2.2.jre8</version>
    </dependency>
    

    See https://github.com/Microsoft/mssql-jdbc for actual latest versions.

    0 讨论(0)
提交回复
热议问题