Exemple #1
0
 private void init() throws SQLException {
   stmtEpisodeExiste =
       cx.getConnection()
           .prepareStatement(
               "SELECT * FROM Episode WHERE titreSerie = ? AND anneeSortieSerie = ?"
                   + " AND noSaison = ? AND noEpisode = ?");
   stmtAjouterEpisode =
       cx.getConnection()
           .prepareStatement(
               "INSERT INTO Episode (titre, titreSerie, anneeSortieSerie,"
                   + " noSaison, noEpisode, description, dateDiffusion)"
                   + " VALUES (?, ?, ?, ?, ?, ?, ?)");
 }
 /** Test of getConnection method, of class Connexion. */
 @Test
 public void testGetConnection() throws Exception {
   System.out.println("getConnection");
   Connection expResult = null;
   Connection result = Connexion.getConnection();
   assertTrue(expResult != result);
 }
Exemple #3
0
 private void init() throws SQLException {
   stmGetPersonne = cx.getConnection().prepareStatement("SELECT * FROM Personne WHERE nom = ?");
   stmInsertPersonne =
       cx.getConnection()
           .prepareStatement(
               "INSERT INTO Personne (nom, datenaissance, lieunaissance, sexe) VALUES(?, ?, ?, ?)");
   stmDeletePersonne = cx.getConnection().prepareStatement("DELETE FROM Personne WHERE nom = ?");
   stmtGetRealisateur =
       cx.getConnection()
           .prepareStatement(
               "SELECT * FROM personne WHERE nom IN (SELECT DISTINCT realisateur FROM Film)");
   stmtGetActeurDeSerie =
       cx.getConnection()
           .prepareStatement(
               "SELECT * FROM personne WHERE nom IN (SELECT DISTINCT nomActeur FROM RoleEpisode WHERE titreSerie = ? AND anneeSortieSerie = ?)");
 }
Exemple #4
0
 /** Creation d'une instance. Précompilation d'énoncés SQL. */
 public Membre(Connexion cx) throws SQLException {
   this.cx = cx;
   this.stmtExiste =
       cx.getConnection()
           .prepareStatement(
               "select idMembre, nom, telephone, limitePret, nbpret from membre where idmembre = ?");
   this.stmtInsert =
       cx.getConnection()
           .prepareStatement(
               "insert into membre (idmembre, nom, telephone, limitepret, nbpret) "
                   + "values (?,?,?,?,0)");
   this.stmtUpdateIncrNbPret =
       cx.getConnection()
           .prepareStatement("update membre set nbpret = nbPret + 1 where idMembre = ?");
   this.stmtUpdateDecNbPret =
       cx.getConnection()
           .prepareStatement("update membre set nbpret = nbPret - 1 where idMembre = ?");
   this.stmtDelete = cx.getConnection().prepareStatement("delete from membre where idmembre = ?");
 }
Exemple #5
0
  public void enregistrer_login() {
    String sql,
        nomI,
        prenomI,
        date_naissanceI,
        emailI,
        passwordI1,
        passwordI2,
        adresseI,
        villeI,
        code_postalI,
        telephoneI,
        mobileI,
        id_couleurI,
        type_utilisateurI;

    Connexion maBDD = new Connexion("localhost", "root", "", "autodrive");
    maBDD.seConnecter();
    try {
      nomI = this.nomI.getText();
      prenomI = this.prenomI.getText();
      date_naissanceI = this.date_naissanceI.getText();
      emailI = this.emailI.getText();
      passwordI1 = this.passwordI1.getText();
      passwordI2 = this.passwordI2.getText();
      adresseI = this.adresseI.getText();
      villeI = this.villeI.getText();
      code_postalI = this.code_postalI.getText();
      telephoneI = this.telephoneI.getText();
      mobileI = this.mobileI.getText();

      // moyPaiement=txtmoy.getSelectedText();
      System.out.println(
          nomI
              + " "
              + prenomI
              + " "
              + date_naissanceI
              + ""
              + emailI
              + " "
              + passwordI1
              + " "
              + adresseI
              + " "
              + villeI
              + ""
              + code_postalI
              + " "
              + telephoneI
              + " "
              + mobileI);

      // insertion
      Statement unStatement = maBDD.getConnection().createStatement();
      // ResultSet unResultat = unStatement.executeQuery(sql);
      sql =
          "INSERT INTO utilisateurs (nom,prenom,date_naissance,email,password,adresse,ville,code_postal,telephone,mobile) VALUES ('"
              + this.nomI.getText()
              + "','"
              + this.prenomI.getText()
              + "','"
              + this.date_naissanceI.getText()
              + "','"
              + this.emailI.getText()
              + "','"
              + this.passwordI1.getText()
              + "','"
              + this.adresseI.getText()
              + "','"
              + this.villeI.getText()
              + "','"
              + this.code_postalI.getText()
              + "','"
              + this.telephoneI.getText()
              + "','"
              + this.mobileI.getText()
              + ")";
      unStatement.executeUpdate(sql);
      // System.out.println(sql+" ligne insérée");
      JOptionPane.showMessageDialog(this, "Votre compte à bien été ajouter");
      unStatement.close();
      unStatement.close();

    } catch (SQLException exp) {
      JOptionPane.showMessageDialog(
          null, exp.getMessage(), "ERREUR SUR LA REQUETTE ! ", JOptionPane.ERROR_MESSAGE);
    }
    maBDD.seDeconnecter();
  }
Exemple #6
0
  public void enregistrer_edit() {

    String sql,
        nom,
        prenom,
        date_naissance,
        email,
        password1,
        password2,
        adresse,
        ville,
        code_postal,
        telephone,
        mobile,
        id_couleur,
        type_utilisateur;

    Connexion maBDD = new Connexion("localhost", "root", "", "autodrive");
    maBDD.seConnecter();
    try {
      nom = this.nom.getText();
      prenom = this.prenom.getText();
      date_naissance = this.date_naissance.getText();
      email = this.email.getText();
      password1 = this.password1.getText();
      password2 = this.password2.getText();
      adresse = this.adresse.getText();
      ville = this.ville.getText();
      code_postal = this.code_postal.getText();
      telephone = this.telephone.getText();
      mobile = this.mobile.getText();

      /*		calendar_id=this.calendar_id.getToolTipText();
      utc_id=this.utc_id.getToolTipText();
      title=this.title.getToolTipText(); */

      // moyPaiement=txtmoy.getSelectedText();
      System.out.println(
          nom
              + " "
              + prenom
              + " "
              + date_naissance
              + ""
              + email
              + " "
              + password1
              + " "
              + adresse
              + " "
              + ville
              + ""
              + code_postal
              + " "
              + telephone
              + " "
              + mobile);

      // insertion
      Statement unStatement = maBDD.getConnection().createStatement();
      // ResultSet unResultat = unStatement.executeQuery(sql);
      sql =
          "UPDATE utilisateurs SET nom = nom, prenom = prenom, date_naissance = date_naissance, email = email, password1 = password, adresse = adresse, ville = ville, code_postal = code_postal, telephone = telephone, mobile = mobile where id_utilisateur = id_utilisateur";

      unStatement.executeUpdate(sql);
      // System.out.println(sql+" ligne insérée");
      JOptionPane.showMessageDialog(this, "Votre compte à bien été modifier");

      unStatement.close();
      unStatement.close();

    } catch (SQLException exp) {
      JOptionPane.showMessageDialog(
          null, exp.getMessage(), "ERREUR SUR LA REQUETTE ! ", JOptionPane.ERROR_MESSAGE);
    }
    maBDD.seDeconnecter();
  }