Adding Microsoft SQL Server JDBC driver to Nexus and local maven repository

The Microsoft SQL Server JDBC driver is not available in public repositories because of licensing issues but it is easy to install into a company wide repository like Sonatype Nexus or into the local repository on your machine. This procedure can be used for other libraries as well.

Step 1 : Download the driver from http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=11774

Step 2: Extract the file and locate the sqljdbc.jar and sqljdbc4.jar. The table below indicates the usage of the jars respectively.

JAR

Description

sqljdbc.jar sqljdbc.jar class library provides support for JDBC 3.0.sqljdbc.jar class library requires a Java Runtime Environment (JRE) of version 5.0. Using sqljdbc.jar on JRE 6.0 will throw an exception when connecting to a database.The JDBC Driver does not support JRE 1.4. You must upgrade JRE 1.4 to either JRE 5.0 or JRE 6.0 when using the JDBC Driver. In some cases, you might need to recompile your application because it might not be compatible with JDK 5.0 or later. For more information, see the documentation on Sun Microsystems Web site.
sqljdbc4.jar sqljdbc4.jar class library provides support for JDBC 4.0. It includes all of the features of the sqljdbc.jar as well as the new JDBC 4.0 methods.sqljdbc4.jar class library requires a Java Runtime Environment (JRE) of version 6.0. Using sqljdbc4.jar on JRE 1.4 or 5.0 will throw an exception.Use sqljdbc4.jar when your application must run on JRE 6.0, even if your application does not use JDBC 4.0 features.

Step 3: If you have Nexus then use the following pom.xml to add the sqljdbc.jar

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <modelVersion>4.0.0</modelVersion>
    <groupId>com.microsoft.sqlserver</groupId>
    <artifactId>sqljdbc</artifactId>
    <version>4.0.2206.100</version>
</project>

Step 4: Select the 3rd Party Releases repository in Nexus. In the image I am showing my local Nexus 2.0 repository

3rd party repository

Step 5: Click the Artifact Upload tab.

a. Select the GAV Definition: From POM

b. POM file name: Select the file containing the pom.xml from step 3

c. Select artifacts to upload: Select the sqljdbc.jar from enu folder in the extracted zip folder

Adding sqljdbc.jar to Nexus 3rd Party Releases

Step 6: Select Upload

Uploaded

Step 7: Installing the sqljdbc4.jar uses the following pom.xml and the steps outlined above

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <modelVersion>4.0.0</modelVersion>
    <groupId>com.microsoft.sqlserver</groupId>
    <artifactId>sqljdbc4</artifactId>
    <version>4.0.2206.100</version>
</project>

Step 8: If you do not have Sonatype Nexus, then to install the libraries into the local repository using the following command. You do not need the pom.xml files since these will be created by Maven.

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

Step 9: Reference the library in you project

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

NOTE: Tomorrow I will be deploying the driver into Apache Karaf.

About these ads

Tags:

3 responses to “Adding Microsoft SQL Server JDBC driver to Nexus and local maven repository”

  1. Pablo says :

    Nice and quick.

    Remark, In step three shouldnt version be 3.0 and not 4.0, it seems you have repeated the same pom.xml, was abit of confusing in the start.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Java Magic

Blog about Tapestry5, Plastic and related technologies

Steps & Leaps

Thoughts and Comments on (Mainly) Creativity, Innovation and Management

Facilitating Agility

Scrum and Agile Facilitation

Jan's Blog

Development and technology stuff I haven't easily found

WatirMelon

A 93% Software Testing Blog by Alister Scott

Dan Haywood

domain driven design, restful objects, apache isis, the naked objects pattern, agile and more

Marko A. Rodriguez

Supporting the Emerging Graph Landscape

A developer's journal

On Oracle, JEE, SOA and whatmore

RedStack

Musings on Integration with Oracle Fusion Middleware

oracle-stack-support

Oracle Stack Support (One Window Support)

Struberg's Blog

Yet another blog site?

Exit Condition

Andrew Lee Rubinger

Antonio's Blog

A blog mainly about Java

Sematext Blog

Monitoring, Log Management, Search, Big Data Analytics

WordPress.com News

The latest news on WordPress.com and the WordPress community.

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: