1

I have a JavaFX project using MS access as a database, after creating executable JAR in IntelliJ, while running the jar in CMD, i get the following exception

net.ucanaccess.jdbc.UcanaccessSQLException: UCAExc:::4.x.x given file does not exist: resource\Account_Record.accdb
    at net.ucanaccess.jdbc.UcanaccessDriver.connect(UcanaccessDriver.java:231)
    at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:677)
    at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:251)

which indicateds the the database file is not reacheable by my following comection:

Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
        conn = DriverManager.getConnection("jdbc:ucanaccess://resource//Account_Record.accdb);

i have checked the Jar file, and yes it have the "Account_Record.accdb" inside it, and while running the JAR file inside IntelliJ IDE, i get no errors, but not able to make it stand alone !

7odaifa_ab
  • 19
  • 5
  • why do you think that the driver knows to look inside a jar file to find the DB ? – Scary Wombat May 17 '21 at 02:08
  • @ScaryWombat that's what i got that other driver can, from this [Stack overflow Question](https://stackoverflow.com/questions/12019974/how-to-include-sqlite-database-in-executable-jar) – 7odaifa_ab May 17 '21 at 16:32
  • Did you try it using the syntax in the accepted answer, instead of the syntax you posted in the question? – James_D May 17 '21 at 17:14
  • @James_D Yes i did, and many other ways as well, yet nothing worked ^_^ – 7odaifa_ab May 17 '21 at 20:08
  • The link that you provided was for sqlite not UcanAccess, so again why do you think it can read a DB in a jar? – Scary Wombat May 18 '21 at 00:27

1 Answers1

1

UcanAccess looks for the database just in the filesystem, you have to extract it by your own code

jamadei
  • 1,700
  • 9
  • 8