Java系列: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:

  5. 1

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

  6. You should see something similar to this:

  7. 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.

    http://claude.betancourt.us/add-microsoft-sql-jdbc-driver-to-maven/

来自为知笔记(Wiz)

时间: 2024-11-08 21:49:15

Java系列:Add Microsoft SQL JDBC driver to Maven的相关文章

Add Microsoft SQL JDBC driver to Maven(转)

from:http://claude.betancourt.us/add-microsoft-sql-jdbc-driver-to-maven/ Add Microsoft SQL JDBC driver to Maven March 13, 2012 Framework / How-To / Tutorials Maven does not directly support some libraries, like Microsoft's SQL Server JDBC. This tutor

添加Microsoft SQL JDBC driver 到 Maven

主要步骤如下: 1. 本地下载sqljdbc4.jar 2. 解压到本地文件夹中,并找到sqljdbc4.jar路径 3. 打开命令窗口,打开至工程目录,执行以下语句(前提:先配置好maven环境变量) mvn install:install-file -Dfile=e:\sqljdbc4.jar -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc4 -Dversion=4.0 -Dpackaging=jar 4."BUILD SUCCE

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver解决方案

昨天整理桌面的时候将桌面的一堆文件移动到F盘去了,结果导致原来建的一些项目名称全部出现红色感叹号,打开一看,原来是因为我把hibernate的那些jar包移走了,导致user library里那些jar在原来的路径里找不到了,所以出现红色感叹号,在写新的项目的时候就不能把原来写的羡慕copy过来改了,只好重新新建了个java project,然后重新导包,编好代码运行一下,报了如下错误:java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver 解决方法

今天用 myeclipse 写了个工程.结果最后报错,错误信息如下: java.lang.ClassNotFoundException: com.mysql.jdbc.Driverat org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1647)at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoade

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

项目中已经存在 mysql-connector-java-5.1.7-bin.jar   但是运行还是提示“java.lang.ClassNotFoundException: com.mysql.jdbc.Driver” 解决方法:将mysql-connector-java-5.1.7-bin.jar拷贝到tomcat 下的lib目录下即可

java web mysql.jar java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver 折腾了一上午,找到了这错误的原因.哎……悲剧! 确认包已经被导入web工程目录. 原来是tomcat找不到MYSQL JAR包的问题.后来又把mysql-connector-java-5.1.7-bin.jar导入到tomcat的lib目录下面就ok了,嘿…… 在java项目中,只需要引入mysql-connector-java-5.1.7-bin.jar就可以运行java项目. 在w

Unofficial Microsoft SQL Server Driver for PHP (sqlsrv)非官方的PHP SQL Server 驱动

原文 Unofficial Microsoft SQL Server Driver for PHP (sqlsrv) Here are unofficial modified builds of Microsoft's sqlsrv and pdo_sqlsrv drivers for PHP, version 3.0, for: PHP 5.6 for Windows Vista/2008 and above (32 and 64 bit) PHP 5.5 for Windows Vista/

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver问题

java.lang.ClassNotFoundException: com.mysql.jdbc.Driverat org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1647)at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1493)at java.lang.Class.forN

java.lang.UnsupportedClassVersionError: com/mysql/jdbc/Driver : Unsupported major.minor version 52.0

版本为: jdk1.7.0_80 mysql-connector-java-5.1.46-bin.jar 解决办法: 升级JDK或者降级MySQL Connector/J为mysql-connector-java-5.1.46-bin.jar java.lang.UnsupportedClassVersionError: com/mysql/jdbc/Driver : Unsupported major.minor version 52.0 at java.lang.ClassLoader.de