ZJC ZJC - 1 year ago 84
Java Question

SQLite database does not exist according to Java application

I have looked at every possible answer on this site, nothing quite covers the issue.

I followed a tutorial and tried using the Firefox SQLite Manager AND using the SQLite3 shell to create the same database.

public class DBConnector {
static Connection conn = null;
public static Connection connect()
conn = DriverManager.getConnection("jdbc:sqlite:‪C:\\Users\\John\\Desktop\\database.db");
return conn;
catch(Exception e){
return null;

Whenever I run this i get:

java.sql.SQLException: path to '‪C:\Users\John\Desktop\database.db': 'C:\Users\John\Documents\NetBeansProjects\JBook\‪C:' does not exist

I'm new enough to this to where I have no idea what the issue is.
Any help is greatly appreciated. And yes, I have looked at all of the other questions posted and tried using their answers, to no avail.

Thanks again

EDIT: A couple of the possible answers already listed have included to change the .db extension to .sqlite
This did NOT work.
Another simply showed how to use an absolute path, once again, I had that covered and it didn't work.
Another talked about JUnit test and some issue they were having which was irrelevant to what I am doing

Answer Source

Finally got the issue:

Copy the path you specified in notepad++ and set encoding to ansi and you will see some special character before C: which is causing issue .

conn = DriverManager.getConnection("jdbc:sqlite:‪C:\\Users\\ravi\\Desktop\\database.db");
conn = DriverManager.getConnection("jdbc:sqlite:C:\\Users\\ravi\\Desktop\\database.db");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download