IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Spring Java Discussion :

Un probleme dans la Methode DELETE dans une RESTful web service avec Spring 3 mvc cvp


Sujet :

Spring Java

  1. #1
    Nouveau Candidat au Club
    Homme Profil pro
    Webmaster
    Inscrit en
    Février 2013
    Messages
    1
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Webmaster
    Secteur : Bâtiment

    Informations forums :
    Inscription : Février 2013
    Messages : 1
    Points : 1
    Points
    1
    Par défaut Un probleme dans la Methode DELETE dans une RESTful web service avec Spring 3 mvc cvp
    Un probleme dans la Methode DELETE dans une RESTful web service avec Spring 3 mvc ...
    Jais besoin de resoudre ce probleme


    Nom : EEEEEEEEEEEEE.JPG
Affichages : 405
Taille : 21,5 Ko

    on a la Connextion
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    	public Connection connexion() throws SQLException{
    		String url = "jdbc:mysql://localhost:3306/etud";
    		Connection con = DriverManager.getConnection(url,"root","");
    		return con;
    	}

    on a Le CONTROLEUR
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
    package com.tp.controller;
     
     
    import java.sql.SQLException;
    import java.util.ArrayList;
    import java.util.List;
     
    import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
    import org.springframework.http.HttpStatus;
    import org.springframework.http.ResponseEntity;
    import org.springframework.web.bind.annotation.PathVariable;
    import org.springframework.web.bind.annotation.RequestBody;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;
    import org.springframework.web.bind.annotation.ResponseBody;
    import org.springframework.web.bind.annotation.RestController;
     
    import com.tp.model.Etudiant;
    import com.tp.service.EtudiantService;
     
     
    //  @RestController annotation, which marks the class as a controller
    @RestController
     
    @RequestMapping("etudiants")
    @EnableAutoConfiguration
    public class EtudiantController {	
     
    	@RequestMapping(value = {"/supprimer/{idDeleted}"}, method = RequestMethod.DELETE)
    	public void supprimer(@PathVariable("idDeleted") int numEtud ) throws ClassNotFoundException, SQLException {	
     
             Etudiant etudiant = new Etudiant();
    		try {
     
     
    			Connection con = etudiantService.connexion();
    			Statement stSupp = con.createStatement() ;
    			stSupp.executeUpdate("DELETE FROM etudiant WHERE id="+etudiant.getId() );
     
    		} catch (ClassNotFoundException e) {
    			e.printStackTrace();
    		} catch (SQLException e) {
    			e.printStackTrace();
    		}
    	}
     
    }

    ona la classe de resourece ETUDIANT
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
     
     
    package com.tp.model;
     
    public class Etudiant {
    	// attributes
    	int id;
    	private String nom;
    	private String prenom;
    	private String sexe;
    	private String mail;
    	private String nationalite;
    	private String langue;
    	private String codePostal;
    	private String numTel;
    	private String dateNaissance;
    	private String Address;
     
    	// getter and setter
    	public int getId() {
    		return id;
    	}
     
    	public void setId(int id) {
    		this.id = id;
    	}
     
    	//@Column(name="nom",nullable=false,updatable=false)
    	public String getNom() {
    		return nom;
    	}
     
    	public void setNom(String nom) {
    		this.nom = nom;
    	}
     
    	public String getPrenom() {
    		return prenom;
    	}
     
    	public void setPrenom(String prenom) {
    		this.prenom = prenom;
    	}
     
    	public String getSexe() {
    		return sexe;
    	}
     
    	public void setSexe(String sexe) {
    		this.sexe = sexe;
    	}
     
    	public String getMail() {
    		return mail;
    	}
     
    	public void setMail(String mail) {
    		this.mail = mail;
    	}
     
    	public String getNationalite() {
    		return nationalite;
    	}
     
    	public void setNationalite(String nationalite) {
    		this.nationalite = nationalite;
    	}
     
    	public String getLangue() {
    		return langue;
    	}
     
    	public void setLangue(String langue) {
    		this.langue = langue;
    	}
     
    	public String getCodePostal() {
    		return codePostal;
    	}
     
    	public void setCodePostal(String codePostal) {
    		this.codePostal = codePostal;
    	}
     
    	public String getNumTel() {
    		return numTel;
    	}
     
    	public void setNumTel(String numTel) {
    		this.numTel = numTel;
    	}
     
    	public String getDateNaissance() {
    		return dateNaissance;
    	}
     
    	public void setDateNaissance(String dateNaissance) {
    		this.dateNaissance = dateNaissance;
    	}
     
    	public String getAddress() {
    		return Address;
    	}
     
    	public void setAddress(String address) {
    		Address = address;
    	}
     
     
    }

    et quand je test ... l'operation et valide
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
     
    package com.tp.service;
     
    import java.sql.SQLException;
     
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
    import org.springframework.context.annotation.ComponentScan;
    import org.springframework.context.annotation.Configuration;
     
     
    @Configuration
    @ComponentScan(basePackages={"com.tp.controller"})
    @EnableAutoConfiguration
    public class WebServiceMain {
     
     
    	public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, SQLException {
    		SpringApplication.run(WebServiceMain.class, args);
     
    	}
    }

    Nom : Untitled-1 copy.jpg
Affichages : 417
Taille : 29,1 Ko

    Mais le probleme est : Aucun modification a labase de donnee et aucun erreur apparaite !!!!!!!!!

    Aidez moi svp
    Merci

  2. #2
    Membre régulier
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mai 2013
    Messages
    36
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2013
    Messages : 36
    Points : 71
    Points
    71
    Par défaut
    tu voulais plutot ecrire
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    stSupp.executeUpdate("DELETE FROM etudiant WHERE id="+numEtud);
    ?

    (Sinon pour les requete DELETE, essaies de retourner une reponse autre que vide)

Discussions similaires

  1. [WD12] Info manquante dans le code source d'une page web
    Par zouzoukha dans le forum WinDev
    Réponses: 12
    Dernier message: 18/06/2012, 05h21
  2. Réponses: 4
    Dernier message: 24/05/2010, 14h06
  3. Réponses: 1
    Dernier message: 16/04/2010, 09h19
  4. Réponses: 5
    Dernier message: 06/08/2006, 20h38

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo