0

NOT A DUPLICATE

I am using firefox SQLite manager and I created one database.sqlite file which I put into my project directory before src directory. When I compile code from IDE, it can access the database since it has tables but When I execute JAR file of my project . It creates a new database.sqlite exactly in same directory where my JAR is, But when opened it has no table, nothing. And thus my application doesn't even start(login doesn't work).

Can't figure out how to solve that! Also some threads say, one can't update SQLite database that resides in JAR file. In my case it is created as soon as I double click on Jar file. So dO I need to change anything?And how to solve that no table problem mentioned above?Thank you.

I did some changes like suggested on previous threads but none of them helped !

Connection conn = DriverManager.getConnection("jdbc:sqlite::resource:database.sqlite");
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
minigeek
  • 2,766
  • 1
  • 25
  • 35
  • A embedded resource may not be loadable by the jdbc driver, it certainly won't be writable – MadProgrammer Apr 11 '17 at 20:37
  • @MadProgrammer then how do i use my sqlite file? I want database in my application and application is supposed to be JAR – minigeek Apr 12 '17 at 02:51
  • I runs when i keep my good .sqlite file in the folder where jar is..but i want it to be created automatically – minigeek Apr 12 '17 at 02:56
  • You can use `Class#getAsResource` to get a URL reference to the embedded resource, you can try using that as part of the connection path or extract the database to a known location – MadProgrammer Apr 12 '17 at 03:14

0 Answers0