2

I am using maven. i am using sqlserver2010 database. what is the corresponding maven dependency to use com.microsoft.sqlserver.jdbc.SQLServerDriver ? Also in which repository i can find it to get downloaded?

Thanks!

user1016403
  • 12,151
  • 35
  • 108
  • 137
  • Related to this [SO question](http://stackoverflow.com/questions/6942407/setting-up-maven-dependency-for-sql-server). Looks like you will need to manually install... – Raghuram Jun 14 '12 at 10:52

2 Answers2

2

I think this is the one.

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

download the jar from here.

To add to the repository.

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

Hope this helps you. Cheers.

UPDATED The new dependency edited here.

Japan Trivedi
  • 4,445
  • 2
  • 23
  • 44
  • i added this but this is not there in maven central repository. – user1016403 Jun 14 '12 at 10:58
  • added the command to add this dependency to your repository and then add the dependency in your pom. – Japan Trivedi Jun 14 '12 at 11:00
  • Also you need to download the jar file from the link provided in my updated answer. :-) – Japan Trivedi Jun 14 '12 at 11:03
  • where should i execute the command? in command prompt do i need to be inside .m2 and run the command? Thanks! – user1016403 Jun 14 '12 at 11:15
  • if you have added M2_HOME in your env variables then you can run from any place in your folder system. Otherwise you need to be in the bin folder of your maven installation directory. – Japan Trivedi Jun 14 '12 at 11:17
  • i tried but i am getting below error.[INFO] Error installing artifact 'com.microsoft.sqlserver:sqljdbc4:jar': Error i nstalling artifact: File C:\apache-maven-2.1.0\bin\sqljdbc4.jar does not exist – user1016403 Jun 14 '12 at 11:24
  • you need to copy and paste the download jar files from the link I provided in asnwer to the path you are getting error. – Japan Trivedi Jun 14 '12 at 11:35
  • i have placed the sqljdbc4-3.0 jar in bin directory and run the command but of no use... – user1016403 Jun 14 '12 at 11:37
  • you have to change the name of jar file in the command. Are you using as it is I have placed in the answer?? – Japan Trivedi Jun 14 '12 at 12:09
2

Download official driver and install it into your private, internal repository (like Nexus) as 3rd party stuff or into local repo (if you don't use Nexus) by mvn install:install-file ....

Alternatively use jTDS and get the artifact from Maven Central:

<dependency>
    <groupId>net.sourceforge.jtds</groupId>
    <artifactId>jtds</artifactId>
    <version>1.2.4</version>
    <scope>runtime</scope>
</dependency>
Michał Kalinowski
  • 16,925
  • 5
  • 35
  • 48