samiapirou
Messages postés112Date d'inscriptiondimanche 16 juin 2013StatutMembreDernière intervention11 novembre 2015
-
22 avril 2015 à 11:46
bonjour ,svp pouvez m'aider a résoudre cette erreur c'est urgent,
a chaque fois que je fait l'ajout j'ai une exception : MySQLIntegrityConstraintViolationException
voici ce qui m'affiche sur la console:
WARNING *********** NetBeans HTTP Monitor ************
The request cannot be recorded most likely because the NetBeans HTTP Monitor module is disabled.
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'lib_spec' cannot be null
try { Class.forName("com.mysql.jdbc.Driver"); Connection cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/bdd","root",""); PreparedStatement pr=cn.prepareStatement("DELETE FROM specialite WHERE id_spec = ? ");
pr.setInt(1, id_spec); pr.execute();
}
// Etudiants.add(e); catch (Exception ex) {
ex.printStackTrace();
}
} public ArrayList getAll(){ ArrayList listSpec= new ArrayList<Specialite>(); try { Class.forName("com.mysql.jdbc.Driver"); Connection cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/bdd","root",""); PreparedStatement pr = cn.prepareStatement("SELECT * FROM specialite");
ResultSet rs = pr.executeQuery(); while(rs.next()){ Specialite s = new Specialite(); s.setId_spec(rs.getInt("id_spec")); s.setLib_spec(rs.getString("lib_spec"));
listSpec.add(s);
}
}
//Etudiants.add(e); catch (Exception ex) {
ex.printStackTrace();
}
return listSpec;
}
}
et aussi la servlet:
public class SpecialiteServlet extends HttpServlet { public static final long serialVersionUID = 1L; OperationSepecialite os = new OperationSepecialite();