I have a java web app. I need to point to an existing sqlite database that I have in the project root (in eclipse).
I have all of the required drivers/jars.
The problem is that code to select from my sqlite database tables runs against a newly created database. I get an error that my table "Table1" doesn't exist. I believe this is because a new database is being created as opposed to using the existing sqlite database in the root with the tables and data that I need.
Does anyone know how I can force this local sqlite database to be used?
1 Answer 1
Per the SQLite docs, a new database will be created by default if it doesn't find an existing one -- so the most likely explanation is that the path in your connection string isn't pointing to your pre-existing database.
See the question here about relative paths in web apps: if your web-app is a servlet, use ServletContext.getResource to get the path to your database to use in the connection string. So, if your existing database is in /WEB-INF:
ServletContext.getResource("/WEB-INF/my.db");