'Can't access MySQL database from exe but works fine in IDE and jar

I have a small GUI application that is supposed to access a local MySQL database. It works fine from my IDE and jar file but once I use the jpackaging tool to turn it into an exe it does not connect to the database and with no exceptions thrown. Here is my code:

    public static boolean connectDatabase(String user, String passwd) {
    try {
        ExceptionDialog.showErrorAlert("Connect Database Entry 1");
        if (Timestamp.from(Instant.now()).after(VALIDATION_DATE)) {
            ExceptionDialog.showErrorAlert("Woops bye bye");
            ExceptionDialog.showErrorAlert("Connect Database Entry 2");
            return false;
        }
        ExceptionDialog.showErrorAlert("Connect Database Entry 3");
        Class.forName("com.mysql.cj.jdbc.Driver");
        ExceptionDialog.showErrorAlert("Connect Database Entry 4");

        connect = DriverManager.getConnection("jdbc:mysql://127.0.0.1/xtreme_inv_man_v_0001?", user, passwd);
        ExceptionDialog.showErrorAlert("Connect Database Entry 5");
        Timestamp lastLogin = SQL_Login.sql_retrieveLastLogin();
        if (lastLogin == null || lastLogin.before(Timestamp.from(Instant.now()))) {
            ExceptionDialog.showErrorAlert("Connect Database Entry 6");
            SQL_Login.sql_updateLogin();
        } else {
            ExceptionDialog.showErrorAlert("Connect Database Entry 7");
            ExceptionDialog.showErrorAlert("Your clock is wrong ");
            return false;
        }
        ExceptionDialog.showErrorAlert("Connect Database Entry 8");
        MySQLAccess.user = user;
        return true;
    } catch (Exception e) {
        ExceptionDialog.showErrorAlert("Connect Database Entry 9");
        e.printStackTrace();
        ExceptionDialog.createDialog(e);
        return false;
    }
}

Upon successful Login I expect Entries 1,3,4,5,6 and 8 to be executed which is what I get executed when I launch from IDE or the jar, however, when I try to launch the exe Entries 1,3 and 4 gets executed and it stops. I can tell no exception has been thrown or else Entry 9 would have launched but it doesn't which means it gets stuck somehow over at DriverManager.getConnection

This is how I package my app using Jpackaging tool

jpackage --type exe --input . --dest . --main-jar .\Roots.jar --main-class com.example.roots.App --module-path "C:\Program Files\Java\javafx-jmods-18.0.1" --add-modules javafx.controls,javafx.fxml,java.sql,javafx.graphics,javafx.base --win-shortcut --win-menu


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source