Setting up maven dependency for SQL Server
Download the driver JAR from the link provided by Olaf and add it to your local Maven repository with;
mvn install:install-file -Dfile=sqljdbc4.jar -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc4 -Dversion=4.0 -Dpackaging=jar
Then add it to your project with;
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</dependency>
Answer for the "new" and "cool" Microsoft.
Yay, SQL Server driver now under MIT license on
- GitHub: https://github.com/Microsoft/mssql-jdbc
- Maven Central: http://search.maven.org/#search%7Cga%7C1%7Cmssql-jdbc
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.1.0.jre8</version>
</dependency>
Answer for the "old" Microsoft:
For my use-case (integration testing) it was sufficient to use a system scope for the JDBC driver's dependency as such:
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>3.0</version>
<scope>system</scope>
<systemPath>${basedir}/lib/sqljdbc4.jar</systemPath>
<optional>true</optional>
</dependency>
That way, I could put the JDBC driver into local version control. No need to have each developer manually set stuff up in their own repositories.
I took inspiration from this answer to another Stack Overflow question and I've also blogged about it here.