0

So i'm having a program that uses an SQLite database called scheduling.db. it is located in the directory src/resources. I create a connection object using the following code:

Connection c = DriverManager.getConnection("jdbc:sqlite:src/resources/scheduling.db");

This works fine in my compiler (IntelliJ IDEA 2017.2.5 Ultimate Edition), but when I build a .jar file from my project and i run it (in Windows 10) gives me the following error:

path to 'src/resources/scheduling.db': 'C:\...\Scheduling_v5_jar\src' does not exist

I thought it was because of the forward slashes or something but nothing really helped, I have not tested it on Linux yet. I'm using the JDBC library sqlite-jdbc-3.21.0.jar

thanks in advance!

Jakob Miserez
  • 96
  • 1
  • 4
  • 2
    When your database file is in a jar it needs to be accessed as a resource, not a file. Check the answer here for information on how your connection URI needs to change. https://stackoverflow.com/questions/12019974/how-to-include-sqlite-database-in-executable-jar – Erik Nedwidek Apr 04 '18 at 18:52
  • The problem is that the file system isn't available to the app that way when you package and run it as an executable JAR. – duffymo Apr 04 '18 at 18:52
  • Using this url did the trick! jdbc:sqlite::resource:resources/scheduling.db, thanks!! – Jakob Miserez Apr 04 '18 at 19:12

0 Answers0