Add Microsoft SQL JDBC driver to Maven

 
 

Maven does not directly support some libraries, like Microsoft’s SQL Server JDBC. This tutorial will show you how to add an external dependency to your local Maven repository. It assumes you have already installed Maven.

Download the JDBC driver for Microsoft SQL Server

    1. Visit the MSDN site for SQL Server and download the latest version of the JDBC driver for your operating system.
    2. Unzip the package
    3. Open a command prompt and switch into the expanded directory where the jar file is located.
    4. Execute the following command. Be sure to modify the jar file name and version as necessary:
1
mvn install : install - file -Dfile=sqljdbc4.jar -Dpackaging=jar -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc4 -Dversion=4.0
    1. You should see something similar to this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven- install -plugin:2.3.1: install - file (default-cli) @ standalone-pom ---
[INFO] Installing /Users/claude/installers/JDBC/sqljdbc_4 .0 /enu/sqljdbc4 .jar to /Users/claude/ .m2 /repository/com/microsoft/sqlserver/sqljdbc4/4 .0 /sqljdbc4-4 .0.jar
[INFO] Installing /var/folders/c6/q1bdtq557kv54783p1g6cbsw0000gp/T/mvninstall1874482299687761721 .pom to /Users/claude/ .m2 /repository/com/microsoft/sqlserver/sqljdbc4/4 .0 /sqljdbc4-4 .0.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time : 1.208s
[INFO] Finished at: Tue Mar 13 14:07:31 EDT 2012
[INFO] Final Memory: 3M /81M
[INFO] ------------------------------------------------------------------------

Modify your POM

Include the new dependency by modifying your project’s pom.xml. Add the following dependency:

1
2
3
4
5
< dependency >
     < groupId >com.microsoft.sqlserver</ groupId >
     < artifactId >sqljdbc4</ artifactId >
     < version >4.0</ version >
</ dependency >

Save the pom.xml file and build the project to make sure no errors exist.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值