0
I am wondering how I could implement the DELETE method of the HTTP web service REST JAVA protocol, when I run it says that I am running the GET and not DELETE method.
//Method called in Web Service
public void remove(Promocao promocao) {
id_conexao = N.Conectar();
String sql = "delete from promocao where idpromocao=?";
try {
stmt = id_conexao.prepareStatement(sql);
stmt.setInt(1, promocao.getIdpromocao());
//executa
stmt.execute();
System.out.println("Promocao Excluida");
} catch (SQLException e) {
System.err.println("ERRO ao excluir promoção - " + e);
} finally {
N.Desconectar();
}
}
//DELETE in Java Web Service
@DELETE
@Path("excluirPromocao")
public void excluir(String content){
Gson g = new Gson();
Promocao P = (Promocao) g.fromJson(content, Promocao.class);
PromocaoOp promo = new PromocaoOp();
promo.remove(P);
}
Do you use any framework? You know how to handle
GET
andPOST
separately?– Jefferson Quesado
I created a Java Web Service using netbeans basically it makes a connection to MYSQL and calls the method to delete I will post what I did
– fabricio b.