I am trying to make a record from a java application but when I clicked the accept button it does not save the data in the DB (Mysql) I am using the IDE Eclipse here I leave the code where I do the registration.
Connection con = null;
try {
con = getConection();
ps=con.prepareStatement("INSERT INTO alumno (num_control,Nombre,fecha_inicio,fecha_termino) VALUES (?,?,?,?)");
ps.setString(1,RegistroAlumno.numc2.getText());
ps.setString(2,RegistroAlumno.nom2.getText());
ps.setDate(3,Date.valueOf(RegistroAlumno.fecha_inicio2.getText()));
ps.setDate(4,Date.valueOf(RegistroAlumno.numc2.getText()));
int res = ps.executeUpdate();
System.out.println("Res= "+res);
if(res > 0 ) {
JOptionPane.showMessageDialog(null," ! Registro exitoso ! ");
RegistroAlumno.LimpiarCajasTextos();
}else {
JOptionPane.showMessageDialog(null," Registro fallido, verifique su conexion a la Base de Datos ... ");
RegistroAlumno.LimpiarCajasTextos();
}
con.close();
}catch(Exception e) {
}