Hello I am learning on my own to access a database, insert, delete, update, etc, in this case I use Access
as a database but I have a problem when inserting data in the table, it generates the following error:
How can I solve it? Here is my code
public class Insertar {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String ruta = "C:\Users\root\Documents\BDPrueba.accdb";
Connection conectar = null;
Statement mistatement = null;
try {
conectar = DriverManager.getConnection("jdbc:ucanaccess://" + ruta, "", "");
System.out.println("Conexion Exitosa");
mistatement = conectar.createStatement();
String nombres = JOptionPane.showInputDialog("Digite Los Nombres");
String apellidos = JOptionPane.showInputDialog("Digite los apellidos");
String id = JOptionPane.showInputDialog("Digite la Identificacion");
String instruccion = "INSERT INTO Administradores (Nombres,Apellidos,Identificacion) VALUES('" + nombres + "', '" + apellidos + "', '" + id + "')";
mistatement.executeUpdate(instruccion);
System.out.println("Insertado con Exito");
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Error: " + e.getMessage());
}
}
}