9

I've created a new Spring Boot project. I'm trying to setup a DataSource to use MSSQL. However I seem to be getting the error "Unable to load class: com.microsoft.sqlserver.jdbc.SQLServerDriver"

I've placed the file jdbcsql4.jar in a folder in my project /lib/jdbcsq4.jar

In my pom.xml file I've added the following:

<dependency>
        <groupId>com.microsoft.sqlserver</groupId>
        <artifactId>sqljdbc4</artifactId>
        <version>4.0</version>
        <scope>system</scope>
        <optional>true</optional>
        <systemPath>${basedir}/lib/sqljdbc4.jar</systemPath>
    </dependency>

I have an application.properties file, and I'm defining the database credentials like this:

secondary.datasource.url = jdbc:sqlserver://1.1.1.1:50109
secondary.datasource.username = sa
secondary.datasource.password = mypassword
secondary.datasource.driver-class-name =     com.microsoft.sqlserver.jdbc.SQLServerDriver

Can anyone possibly indicate where I may be going wrong?

1
  • 3
    When you down vote my question, is there any chance you could explain why? How else am I supposed to improve my questions? Commented Nov 23, 2015 at 11:57

2 Answers 2

4

I managed to solve this issue by following the instructions in this link http://claude.betancourt.us/add-microsoft-sql-jdbc-driver-to-maven/

EDIT: The original link above no longer exists, but here's a similar link. http://biercoff.com/add-microsoft-sql-jdbc-driver-to-maven/

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

2 Comments

The page doesn;t exist. Will be great help if you can explain briefly - or some other pointers
I've added another link as it seems the original link I posted no longer exists
3

For the ppl who facing these issue. Add dependency in POM. Microsoft finally made the driver available on the Maven Central Repository.

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

you can check here. Microsoft link

1 Comment

'Microsoft finally made the driver available...' note that the blog post to which you refer is almost 3 years old, not as old as the question but still old :-)

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.