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.
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.
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 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.
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.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With