Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Maven dependency for sql jdbc driver in pom.xml

 
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I want to add the dependency for sql jdbc driver. Following is the snippet which I have added in pom.xml

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

I then rt. click on my pom.xml and run maven:install

as expected the build fails and it gives the following error:
"Failed to execute goal on project queryutility: Could not resolve dependencies for project : Failure to find com.microsoft.sqlserver:sqljdbc4:jar:4.0 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]"

I even downloaded the sqljdbc4.jar and then manually pasted at the location: \.m2\repository\com\microsoft\sqlserver\sqljdbc4\4.0\

even now the build fails giving the above error.

Please do help me in resolving this error.

Thanks and Regards,
Sid.
 
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Microsoft doesn't give permission to maven to host their JDBC driver in the maven repo. So, you will have to download the JDBC driver, and put it in your own repo
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Two things. First, add a scope tag to the dependency, you should require the JBDC driver only at runtime:



Second, copying the JAR into your local repository directory is not sufficient - Maven expects to find metadata information to locate a dependency. To properly install the JAR in your local repository, use the install-file target of the install plugin:

mvn install:install-file -Dfile=<path-to-jar-file> -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc4 -Dversion=4.0

Maven 2.x used to provide this command line as part of the error message for a missing jar, which I found to be extremely handy; not sure why they stopped doing that in 3.x
 
Siddharth Bhargava
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jayesh A Lalwani wrote:Microsoft doesn't give permission to maven to host their JDBC driver in the maven repo. So, you will have to download the JDBC driver, and put it in your own repo



I do understand that Microsoft doesn't give permission to maven to host their JDBC driver in the maven repo. Therefore I downloaded the sqljdbc4.jar and place it in the repository .m2
Then I ran the pom.xml. Also I would like to tell that I have downloaded the Maven plugin for Eclipse and run maven commands through eclipse. I rt. click on the pom.xml and click on maven install. There I get this error.

I downloaded the JDBC driver. But how do I put it in my own repo and use it ? Please do let me know the procedure.
 
Siddharth Bhargava
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Peter Johnson wrote:Two things. First, add a scope tag to the dependency, you should require the JBDC driver only at runtime:



Second, copying the JAR into your local repository directory is not sufficient - Maven expects to find metadata information to locate a dependency. To properly install the JAR in your local repository, use the install-file target of the install plugin:

mvn install:install-file -Dfile=<path-to-jar-file> -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc4 -Dversion=4.0

Maven 2.x used to provide this command line as part of the error message for a missing jar, which I found to be extremely handy; not sure why they stopped doing that in 3.x




Sure, I would add the scope tag to the dependency in the pom.xml

I have installed maven plugin in eclipse so I run my maven commands through eclipse and not through command prompt. Could you please let me know how do i use the install-file target of the install plugin using Eclipse ? That would be extremely helpful.

Thanks and Regards,
Sid.
 
Peter Johnson
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Um, getting eclipse to do this is probably more hassle than it is worth. Just run the command from a prompt.
    Bookmark Topic Watch Topic
  • New Topic