Search code examples
sql-servermavenrepositoryodbc-sql-server-driver

Include SqlServerDriver on maven project


I have this problem: I have to connect to a sql server db using sqlServerDriver in my maven project. The problem is: i can't find any repository that provide me the artifact:

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

I've read some suggestion about deploying it in it's own repository, but can i redistribuite this Microsoft artifact? Or is there any other way? like physically include the jar on the project and then instruct maven to get the jar as a resource.. (but i haven't idea if this is possible and how to make it..)


Solution

    • First question: "The Microsoft JDBC driver is freely redistributable under a separate Redistribution License that requires registration", as stated on their site.

    • Second question:

      • The artifact is not available via Maven Central, meaning you will need to have it deployed to your own repository (such as Nexus, Artifactory or the likes).

      • Alternatively, as an ugly hack which is strongly discouraged, you can have the library included in your project's directory and define a dependency to it with scope system. You can package it in your final artifact via the maven-assembly-plugin or maven-shade-plugin. (Just to re-iterate: this is highly discouraged).