I'm trying to learn how to make an SQLite database with this tutorial http://www.sqlitetutorial.net/sqlite-java/create-table/ but I'm stuck.
I wrote the code like they said (changing just the name of the class and the path to find the file) using NetBeans.
package createnewtable;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
public class CreateNewTable {
public static void createNewTable(){
//SQLite connection string
String url = "jdbc:sqlite:/Volumes/..../Esercizi/test.db";
//SQL statement for creating a new table
String sql = "CREATE A TABLE IF NOT EXISTS warehouses ("
+ "id integer PRIMARY KEY,"
+ "name text NOT NULL,"
+ "capacity real)";
try (Connection conn = DriverManager.getConnection(url);
Statement stmt = conn.createStatement()){
//Create a new Table
stmt.execute(sql);
} catch(SQLException e){
System.out.println(e.getMessage());
}
}
public static void main(String[] args) {
createNewTable();
}
}
But when I run the code the output is the following:
No suitable driver found for jdbc:sqlite:/Volumes/.../Esercizi/test.db"
Can you help me? Where is my mistake?
Thanks in advance