0

I am developping an app for Windows by myself and have issues with it since it is my first time. My environment is Windows 11 and my terminal uses Visual Studio environment vcvars64. I package my app with the commands gradle clean jlink --info and gradle jpackage -PinstallerType=msi.

My code for accessing the database is the following :

public ConnectionDB() {
   try {
      System.out.print("Connecting to the database... ");
      this.co = DriverManager.getConnection(DB_CONN_URL, DB_USER, DB_PASSWD);
      System.out.println("Connected");
   } catch (SQLException e) {
      System.err.println("Failed");
      e.printStackTrace(System.err);
   }
}

public Connection getCo() {
   return co;
}

public void close() {
   try {
      // Fermeture de la connection
      System.out.print("Disconnecting from the database... ");
      this.co.close();
      System.out.println("disconnected");
   } catch (SQLException e) {
      System.err.println("failed");
      e.printStackTrace(System.err);
   }
}

public ResultSet executeQuery(String query) {
   // System.out.println(query);
   try {
      Statement statement = co.createStatement();
      ResultSet result = statement.executeQuery(query);
      return result;
   } catch (SQLException e) {
      e.printStackTrace();
      System.out.println(e.getMessage());
      System.out.println(e.getErrorCode());
   }
   return null;
}

When launching from my terminal I encounter no error but when I launch the .exe, my calls to my remote database crash for some of them, notably the inserts. When debugging the process running the database connection with Visual Studio, I encounter the following error with each access demand to my remote database : Exception thrown at 0x000001FE3BCBF1B1 in CharacterCreator.exe: 0xC0000005: Access violation reading location 0x0000000000000008.

I have made my researchs but cannot find a clue on what to do to correct this or even dig further into the issue.

Would you happen to have valuable information?

Vincent
  • 35
  • 5
  • What program is `CharacterCreator.exe`? – tgdavies Mar 19 '23 at 20:49
  • Most likely you have not used jpackage adding the correct JDBC driver dependencies, try running with only the jars in the installed directory and see if [win-console](https://stackoverflow.com/questions/62606900/in-java-how-do-you-debug-exe-created-by-jpackage/62621695#62621695) helps – DuncG Mar 19 '23 at 21:15
  • ```CharacterCreator.exe``` is the executable of my application. What do you mean by "running with only the jars in the installed directory"? Thank you for talking about win-console, I didn't know about it. I'll try it when I have some time ! – Vincent Mar 20 '23 at 20:36
  • You say run from terminal works, so substitute every item in that command line with the corresponding item in release directory structure. If you cannot do that you have not packaged the right dependencies. – DuncG Mar 21 '23 at 08:55

0 Answers0