How to include SQLite database in executable Jar?

0 votes

I have created a Swing application that uses SQLite as a local database. The database file is located in project's root directory.


The application runs fine on Eclipse, but when I run the packaged executable Jar, I get the following error:

No such table : table1

This means that the database is not reachable. When I examined the contents of the resulting JAR file, the database file was not there anymore.

In the code, I've linked the database as follows:


My question is, how to include the SQLite database in the executable Jar?

May 7 in Java by kartik
• 27,140 points

1 answer to this question.

0 votes

Hello @kartik,

I have found two different ways to name the filepath depending on how you are trying to access it.

 Assuming you are accessing the db is located in "/yourproject/resource/ or /yourproject/bin/resource" you should use this as your path:

//Eclipse test path
String url = "jdbc:sqlite:resource/mydb.db";


//runnable jar path
String url = "jdbc:sqlite::resource:mydb.db";



Your way also works... by putting the db in /src

Thank You!!

answered May 7 by Niroj
• 58,500 points

Related Questions In Java

+2 votes
10 answers

How to import a jar file in Eclipse?

To import jar file in your Eclipse ...READ MORE

answered May 15, 2018 in Java by sharth
• 3,370 points
0 votes
1 answer

How to run the JAR files in windows?

Following are the steps to run the ...READ MORE

answered May 28, 2018 in Java by Parth
• 4,630 points
0 votes
2 answers

How can we add the local JAR files to the Maven Project in Java?

Firstly I would like to give credit ...READ MORE

answered Nov 5, 2018 in Java by Sushmita
• 6,890 points
0 votes
1 answer

How to run a JAR file in Java?

The command given below will help you ...READ MORE

answered Jun 1, 2018 in Java by Parth
• 4,630 points
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,357 views
0 votes
0 answers
0 votes
1 answer

how to do global variable declaration in java

Hello,​ Global varriable which is defined after the ...READ MORE

answered Apr 3 in Java by Niroj
• 58,500 points
0 votes
2 answers

How to convert InputStream to byte array in Java?

The class IOUtils, lib: ...READ MORE

answered 3 days ago in Java by Anthony