Exception: comlumn cannot be null

Fermé
natasha82 Messages postés 55 Date d'inscription vendredi 20 mars 2015 Statut Membre Dernière intervention 9 juin 2015 - 20 avril 2015 à 10:20
Bonjour, j'ai un probleme quand je clique sur le bouton ajouter une exception qui m'affiche:
la voila:

The request cannot be recorded most likely because the NetBeans HTTP Monitor module is disabled.
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'domaine_forma' cannot be null
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.Util.getInstance(Util.java:381)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1016)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:957)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3376)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3308)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1837)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1961)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2543)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1737)
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:998)
at metier.OperationFormation.add(OperationFormation.java:56)
at Servlet.FormationServlet.doPost(FormationServlet.java:55)






voici mon code :



public void add(Formation f){

try {

Class.forName("com.mysql.jdbc.Driver");
Connection cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/bdd","root","");
PreparedStatement pr=cn.prepareStatement("INSERT INTO formation VALUES(NULL,?,?,?)");



pr.setString(1, f.getDomaine_forma());

pr.setString(2, f.getType_forma());
pr.setString(3, f.getSpec_forma());


pr.execute();

}


// Etudiants.add(e);
catch (Exception ex) {

ex.printStackTrace();

}

}


et voici la servlet:



public class FormationServlet extends HttpServlet {



@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {



OperationFormation of = new OperationFormation();



if (request.getParameter("actionn")!=null){
of.remove(Integer.parseInt(request.getParameter("id_forma")));

// System.out.println("ok");

// traitement


}
else
{
String domaine_forma = request.getParameter("domaine_forma");
String type_forma=request.getParameter("spec_forma");
String spec_forma= request.getParameter("spec_forma");

//creation des objet



Formation f = new Formation(1, domaine_forma, spec_forma, type_forma);
of.add(f);


// traitement


}
FormationBeans ef=new FormationBeans();
ef.setListe(of.getAll());

request.setAttribute("modele", ef);
request.getRequestDispatcher("AjoutFormation.jsp").forward(request, response);
}


}






pouvez vous m'aider svp .Merci