dimanche 11 octobre 2015

Include SQLite database file in JDBC executable JAR, jdbc:sqlite::resource:my.sqlite not working

I read some post in SO about include sqlite database file in project folder. When running in Eclipse, this DB URL is working

DB_URL = "jdbc:sqlite:my.sqlite";

If I put the DB file in src folder

DB_URL = "jdbc:sqlite:src/my.sqlite";

It's working too. But when I export it to executable JAR and run it, it can't read the database. Someone said about (put the db file src folder) :

connection = DriverManager.getConnection("jdbc:sqlite::resource:my.sqlite")

I run the application and got the error message

java.sql.SQLException: resource quanlythuchi2.sqlite not found: java.net.MalformedURLException: no protocol: my.sqlite

Aucun commentaire:

Enregistrer un commentaire