I've established a database connection in my program but after creating a jar program it is throwing an
java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
It looks like program don't see jdbc driver which I have installed and added to artifact:
I've tried changing a versions changing link looking for class name in JDBC but I've found same one that I've used before which worked in intelij but not in jar
There is a code that I'm using for connection
package howareyoufeeling.database;
import java.sql.*;
public class DatabaseOperations {
static Statement statement;
public static void connectWithAzureDatabase() {
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
String connectionUrl =
"jdbc:sqlserver://howareyoufeeling.database.windows.net:1433;" +
"database=HowAreYouFeeling;" +
"user=wikimmax@howareyoufeeling;password=********;" +
"encrypt=true;trustServerCertificate=false;" +
"hostNameInCertificate=*.database.windows.net;loginTimeout=30;";
try {
Connection connection = DriverManager.getConnection(connectionUrl);
System.out.println("Successfull DB connection " + connection.getSchema());
statement = connection.createStatement();
} catch (SQLException e) {
e.printStackTrace();
}
}
public static void sendDataQuery(String query){
try {
statement.execute(query);
} catch (SQLException e) {
e.printStackTrace();
}
}
}
It looks like dependency is not in jar file but it is i checked it by decompiling and file size matches that includes a driver
Please help
