Merci pour la réponse,
j'ai essayé votre solution et ça ne marche toujours pas !!
voici le code ma classe managed bean qui contient ma méthode Delete:
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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| package projet;
import logs.util.JsfUtil;
import logs.util.PaginationHelper;
import java.io.*;
import java.util.ResourceBundle;
import java.lang.Object;
import java.sql.*;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;
import javax.faces.model.SelectItem;
@ManagedBean(name = "accessLogController")
@SessionScoped
public class AccessLogController implements Serializable {
public AccessLogController() {
}
public void Delete() {
Connection con = null;
try{
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/base", "login", "password");
try{
Statement st = con.createStatement();
String sql = "DELETE FROM test";
st.executeUpdate(sql);
}
catch(SQLException s){
System.out.println("SQL statement is not executed!");
}
}
catch (Exception e){
e.printStackTrace();
}
} |
et voici le code de ma bouton :
<h:commandButton value="SubmitQuery" action="#{accessLogController.delete}"></h:commandButton>
et quand je clique sur le bouton rien ne se passe !
Partager