Q: SQLite database path fixed in JAR? I have an application created in Java which uses a SQLite database. This is stored in both the bin and src folders of my project. When exporting (from Eclipse) the JAR it works fine. The application is able to access the database in the JAR. The code I use for the connectionString is as follows: -
public static String connectionString = "jdbc:sqlite::resource:MAIN_DATABASE.sqlite";

My problem is when I move the JAR to a different folder after it has been exported. It resets to the original database at the time of exporting the JAR. So any changes to the database that the application made are lost. If I move it back again to the original path the changes re-appear.
So it appears there is a "hard-coded" path somewhere in the JAR. Does anyone know where and how this is happening. It's like it is creating a new database for each new location that you put the JAR.
Please let me know if I can provide anymore detail to help you with your answer. Apologies if I have not described my problem correctly, I am both new to this site and Java programming. :)
Many thanks

A: Problem sorted. It was to do with how I exported the JAR from Eclipse. If I choose "Package required libraries into generated JAR" instead of "Extract required libraries into generated JAR" I can move the JAR around willy nilly and the database stays in tact.
I shall look to not including the database in the JAR on the final release of my application anyway thinking about it. It would be easy to access, back-up and update the application if the database is external.
