I have written a code to connect to a database using jdbc, I am using openJDK11.0.2 and mssql JDBC driver 8.4.0 x64.
The connection type is windows authentication and below is the dependency that I have used
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>8.4.0.jre11</version>
</dependency>
When I did a MAVEN BUILD, the build succeeded and I executed the JAR using java -jar testJava.jar The code ran perfectly and what query i was trying to execute, it got executed.
But I have to ship that JAR to customer, they will execute the JAR at their end, so I tried executing my JAR on a system that was of my friend's, it errored out saying mssql_jdbc_auth.dll
was missing
Exception in thread "main" com.microsoft.sqlserver.jdbc.SQLServerException: This driver is not configured for integrated authentication
As a work around, I can make my jar work if i paste mssql_jdbc_auth.dll in jdk_/bin/, it is working, but this is not efficient.
I want to ship and point this DLL in my jar using code or some other way, so I looked for maven dependency for this DLL,
I found one
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc_auth</artifactId>
<version>8.4.0.x64</version>
<type>dll</type>
</dependency>
When I saved my pom.xml, the dependency was downloaded in .m2 folder, then I tried to maven build my project but it threw me an error
Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5:single (default-cli) on project egain-identity-management-tool: Failed to create assembly: Error adding file-set for 'com.microsoft.sqlserver:mssql-jdbc_auth:dll:8.4.0.x64' to archive: Error adding archived file-set. PlexusIoResourceCollection not found for: C:\Users\Administrator\.m2\repository\com\microsoft\sqlserver\mssql-jdbc_auth\8.4.0.x64\mssql-jdbc_auth-8.4.0.x64.dll: No such archiver: 'dll'.
Basically it was saying DLL was not found even though it was present.
Is it because I am using openJDK11? I just need to ship a JAR that executes a JDBC operation on someone elses computer without moving any file or any manual arrangements.
Please suggest an approach.
//UPDATE
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.testJava.demoProj.ConsoleTool</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
//THIS IS my POM.XML
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.demo.export</groupId>
<artifactId>demo-management-tool</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo-management-tool</name>
<url>http://maven.apache.org</url>
<!-- <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> -->
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.microsoft.graph</groupId>
<artifactId>microsoft-graph</artifactId>
<version>1.9.0</version>
</dependency>
<dependency>
<groupId>com.microsoft.graph</groupId>
<artifactId>microsoft-graph-core</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.microsoft.graph</groupId>
<artifactId>microsoft-graph-auth</artifactId>
<version>0.2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>args4j</groupId>
<artifactId>args4j</artifactId>
<version>2.0.10</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.13.3</version>
</dependency>
<dependency>
<groupId>com.egain.reporting</groupId>
<artifactId>egain-reporting-core</artifactId>
<version>2.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>8.4.0.jre11</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc_auth</artifactId>
<version>8.4.0.x64</version>
<type>dll</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.testJava.demoProj.ConsoleTool</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>allow-snapshots</id>
<activation><activeByDefault>true</activeByDefault></activation>
<repositories>
<repository>
<id>snapshots-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
</profile>
</profiles>
</project>