1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| try{
Class.forName("com.mysql.jdbc.Driver");
System.out.println("JDBC Load ok");
}
catch (ClassNotFoundException e1)
{
System.out.println (e1);
}
int cod = Integer.parseInt(Text_code_postal.getText());
System.out.println(idclient);
try{
java.sql.Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/Ecommerce","root","");
System.out.println("bonne connexion");
String sqle="INSERT INTO Entreprise (identreprise,idclient,nomentreprise,activite,adresseentreprise,villeentreprise,codepostaleentreprise,paysentreprise)"+
"values("+"NULL,"+idclient+",'"+Text_nom_entreprise.getText()+"','"+Text_activite.getText()+"','"+Text_adresse.getText()+"','"+
Text_ville.getText()+"',"+cod+",'"+Text_pays.getText()+"')";
PreparedStatement pr=conn.prepareStatement(sqle);
pr.executeUpdate(sqle);
pr.close();
conn.close();
System.out.println("enrengistrement entreprise reussi !!");
}catch (SQLException e2)
{
System.out.println(e2);
}
return;
} |
Partager