I'm trying to use sqlite, but it does not work for me.
I'm just making the structure this is the code of my class conexión()
:
class conexion {
String url = "C:\Users\Juan\Documents\NetBeansProjects\JavaApplication4\doc_sal.db";
Connection connect;
public void connect() {
try {
connect = DriverManager.getConnection("jdbc:sqlite:" + url);
if (connect != null) {
System.out.println("Conectado");
}
} catch (SQLException ex) {
System.err.println("No se ha podido conectar a la base de datos\n" + ex.getMessage());
}
}
public void close() {
try {
connect.close();
} catch (SQLException ex) {
Logger.getLogger(conexion.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
Here is my main class:
public class JavaApplication4 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
conexion cn=new conexion();
cn.connect();
}
}
But he always sends me this message
Could not connect to the database
No suitable driver found for jdbc: sqlite: C: \ Users \ Juan \ Documents \ NetBeansProjects \ JavaApplication4 \ doc_sal.db
I would like to know why it does not enter the database.