try {
// db parameters
String url = "jdbc:sqlite: db_path.db";
// create a connection to the database
conn = DriverManager.getConnection(url);
System.out.println("Connection to SQLite has been established.");
} catch (SQLException e) {
System.out.println(e.getMessage());
}
When database is connected a duplicate file is created with same name and size 0Kb inside project folder
String query = "INSERT INTO Path VALUES (?)";
try {
PreparedStatement state = DB_Path.conn.prepareStatement(query);
state.setString(1,path);
} catch (SQLException e) {
System.out.println(e.getMessage());
}
The problem is in url of database file i-e space between jdbc:sqlite: and db_path.db
The correct way is:
url = "jdbc:sqlite:db_path.db;
You can use absolute path too but keep in mind the above line of error, for locating some file in directory, it preferable to use backward slash b/w directories because it is used in windows path system and for java syntax it comes two times like this,
url = "jdbc:sqlite:C:\\Desktop\\db_path.db;
or you can use forward slash too,
url = "jdbc:sqlite:C:/Desktop/db_path.db;