Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 948
Joe Avatar asked Oct 23 '13 09:10

Joe


People also ask

Why sqljdbc4 is missing from the final project jar?

As a result, when creating the final project jar for distribution, sqljdbc4 will again be missing as was indicated in the comment by @Tony regarding runtime error. Microsoft (and Oracle and other third party providers) restrict the distribution of their software as per the ENU/EULA.

Why can't I find this artifact in my Maven repository?

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.

How to install sqljdbc4 in Maven?

You need to download the jar from the Microsoft website, and then manually install it into your local maven repository. Then next time you run maven on your POM it will find the artifact. Make sure sqljdbc4.jar is places in directory you are running command in, otherwise provide full path explicitly.


2 Answers

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.

like image 103
DB5 Avatar answered Sep 17 '22 21:09

DB5


Microsoft recently open sourced their jdbc driver.

You can now find the driver on maven central:

<!-- https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc --> <dependency>     <groupId>com.microsoft.sqlserver</groupId>     <artifactId>mssql-jdbc</artifactId>     <version>6.1.0.jre8</version> </dependency> 

or for java 7:

<!-- https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc --> <dependency>     <groupId>com.microsoft.sqlserver</groupId>     <artifactId>mssql-jdbc</artifactId>     <version>6.1.0.jre7</version> </dependency> 
like image 30
nirmal Avatar answered Sep 17 '22 21:09

nirmal