How to add sqljdbc_auth.dll to my maven project

I am trying to establish a database connection. This is a simple maven project. I have problems with sqljdbc_auth.dll

I added the mssql jdbc driver and added the dependency in pom.xml

  <dependency> <groupId>com.microsoft</groupId> <artifactId>mssql-jdbc</artifactId> <version>4.0.0</version> </dependency> 

This is my try block.

  try { // Establish the connection. SQLServerDataSource ds = new SQLServerDataSource(); ds.setIntegratedSecurity(true); ds.setServerName("BUILDSRV"); ds.setDatabaseName("master"); ds.setIntegratedSecurity(true); con = ds.getConnection(); } 

and i have a mistake

  21.11.2012 18:07:04 com.microsoft.sqlserver.jdbc.AuthenticationJNI <clinit> WARNING: Failed to load the sqljdbc_auth.dll cause :- no sqljdbc_auth in java.library.path com.microsoft.sqlserver.jdbc.SQLServerException: 

I have sqljdbc_auth.dll , but I do not need to point it to C:\windows\... I need to add it to my project with maven. How can i do this?

I tried adding it to pom.xml but it does not work

  <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>1.1</version> <executions> <execution> <id>attach-artifacts</id> <goals> <goal>attach-artifact</goal> </goals> <configuration> <artifacts> <file>target</file> <type>dll</type> </artifacts> </configuration> </execution> </executions> </plugin> </plugins> 

I got one more error while building

 Failed to execute goal org.codehaus.mojo:build-helper-maven-plugin:1.1:attach-artifact (attach-artifacts) on project mavenproject1dbconnect: Unable to parse configuration of mojo org.codehaus.mojo:build-helper-maven-plugin:1.1:attach-artifact for parameter file: Cannot configure instance of org.codehaus.mojo.buildhelper.Artifact from target -> [Help 1] 
+9
source share
1 answer

I do not think you need to use maven-helper-plugin here. The document says that you either need to install the DLL, or specify its path in the java.library.path system variable.

Take a look at http://msdn.microsoft.com/en-us/library/ms378428.aspx#Connectingintegrated

UPDATE: make sure that the dll is distributed with your bank. If you are using maven, put the dll file in the src / main / resources folder. Then make sure that the dll goes beyond the jar, excluding it from the package. Follow the steps similar to those described here . After that, you should have your dll along with your embedded jar file in the target directory

Then, when you run the application pass system properties as a command line parameter java -Djava.library.path=. .

If you prefer not to bother passing parameters through the command line - you can extract the current working directory using System.getProperty("user.dir")) and follow the steps outlined here to set java.library.path to the current directory programmatically in your main method

0
source

All Articles