Missing artifact com.microsoft.sqlserver:sqljdbc4:jar:4.0

CodeNotFound picture CodeNotFound · Oct 23, 2013 · Viewed 166k times · Source

I am trying to add MS SQL driver dependency in my POM.xml file and the following is the dependency.

<dependency>
    <groupId>com.microsoft.sqlserver</groupId>
    <artifactId>sqljdbc4</artifactId>
    <version>4.0</version>
</dependency>

but I get this exception

Missing artifact com.microsoft.sqlserver:sqljdbc4:jar:4.0

I really don't understand the issue.

Answer

DB5 picture DB5 · Oct 23, 2013

UPDATE

Microsoft now provide this artifact in maven central. See @nirmal's answer for further details: https://stackoverflow.com/a/41149866/1570834


ORIGINAL ANSWER

The issue is that Maven can't find this artifact in any of the configured maven repositories.

Unfortunately Microsoft doesn't make this artifact available via any maven repository. You need to download the jar from the Microsoft website, and then manually install it into your local maven repository.

You can do this with the following maven command:

mvn install:install-file -Dfile=sqljdbc4.jar -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc4 -Dversion=4.0 -Dpackaging=jar

Then next time you run maven on your POM it will find the artifact.