~ read.

Add Microsoft SQL JDBC driver to Maven

Found out today that Maven does not directly support some libraries, like Microsoft’s SQL Server JDBC. The reason for that is that this library is not open source and can be stored in global repository. Anyway, i recently was wondering how to add a library to local maven repository to use it in my automation projects. Fast search in Google got me to this blog post. It's really easy :

  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:

mvn install:install-file -Dfile=sqljdbc4.jar -Dpackaging=jar -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc4 -Dversion=4.0
Then you'll get this result :
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ standalone-pom
---
[INFO] Installing C:sqljdbc4.jar to C:IDEConfigs.m2repositorycommicrosoft
sqlserversqljdbc44.0sqljdbc4-4.0.jar
[INFO] Installing C:UsersAF4C0~1.ZAKAppDataLocalTempmvninstall797028335566
232276.pom to C:IDEConfigs.m2repositorycommicrosoftsqlserversqljdbc44.0
sqljdbc4-4.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.925s
[INFO] Finished at: Fri Dec 06 15:59:40 CET 2013
[INFO] Final Memory: 5M/121M
[INFO] ------------------------------------------------------------------------
Now you have this library in your local repository. If you want to use it in your project, then just add dependancy to your pom.xml file.

com.microsoft.sqlserver
sqljdbc4
4.0

That's it. Now you can create connection to SQL Server in your tests
comments powered by Disqus
comments powered by Disqus