Package com.mysql.jdbc

Examples of com.mysql.jdbc.PreparedStatement


  public void ajouterBon(Bon b) {
    Connection connex;
    connex = getConnection();
    String insert = "INSERT INTO `bon`(`id`) VALUES (?)";
    try {
      PreparedStatement preStat = (PreparedStatement) connex.prepareStatement(insert);   
      preStat.setInt(1, b.getId());
      preStat.executeUpdate();
    }catch (SQLException ignore) {     
      System.out.println("erreur ajouterBon : " + ignore);
    }
    closeConnection(connex);
  }
View Full Code Here


    ArrayList<Vente> l = new ArrayList<Vente>();
    Connection connex;
    connex = getConnection();
    String select = "SELECT * FROM `vente` WHERE `idClient` = ?";
    try {
      PreparedStatement preStat = (PreparedStatement) connex.prepareStatement(select);   
      preStat.setInt(1, c.getId());       
      ResultSet rs = preStat.executeQuery();
      while(rs.next()){
        Vente v = new Vente();
        v.setId(rs.getInt(1));
        v.setIdFilm(rs.getString(2));
        v.setDate(rs.getLong(3));
View Full Code Here

    ArrayList<String[]> l = new ArrayList<String[]>();
    Connection connex;
    connex = getConnection();
    String select = "SELECT `idFilm`,`date` FROM `vente` WHERE `idClient` = ? AND `type` = ?";
    try {
      PreparedStatement preStat = (PreparedStatement) connex.prepareStatement(select);   
      preStat.setInt(1, c.getId());
      preStat.setString(2, "l");
      ResultSet rs = preStat.executeQuery();
      while(rs.next()){
        String loc[] = {rs.getString(1) , String.valueOf(rs.getLong(2))};
        l.add(loc);
      }
     
View Full Code Here

    ArrayList<String> l = new ArrayList<String>();
    Connection connex;
    connex = getConnection();
    String select = "SELECT  `idFilm` FROM `vente` WHERE `type` = ?";
    try {
      PreparedStatement preStat = (PreparedStatement) connex.prepareStatement(select);   
      preStat.setString(1, type);       
      ResultSet rs = preStat.executeQuery();
      while(rs.next()){
        l.add(rs.getString(1));
      }
    } catch (SQLException ignore) {     
      System.out.println("erreur filmVendu : " + ignore);
View Full Code Here

  public int bonValide(int id) {
    Connection connex;
    connex = getConnection();
    String select = "SELECT `utilise` FROM `bon` WHERE `id`= ?";
    try {
      PreparedStatement preStat = (PreparedStatement) connex.prepareStatement(select);   
      preStat.setInt(1, id);       
      ResultSet rs = preStat.executeQuery();
      while(rs.next()){
        if(rs.getInt(1) == 0){
          int montant = -1;
          String select2 = "SELECT `prix` FROM `vente` WHERE `id` = ?";
          PreparedStatement preStat2 = (PreparedStatement) connex.prepareStatement(select2);   
          preStat2.setInt(1, id);       
          ResultSet rs2 = preStat2.executeQuery();
          while(rs2.next()){
            montant = rs2.getInt(1);
          }
          return montant;
        }
View Full Code Here

  public void updateBon(Bon b) {
    Connection connex;
    connex = getConnection();
    String select = "UPDATE `bon` SET `idFilm`=?,`dateU`=?,`type`=?,`idClientU`=?,`utilise`=? WHERE `id` = ?";
    try {
      PreparedStatement preStat = (PreparedStatement) connex.prepareStatement(select);   
      preStat.setString(1, b.getIdFilm());
      preStat.setLong(2, b.getDateU());
      preStat.setString(3, b.getType());
      preStat.setInt(4, b.getIdClientU());
      preStat.setInt(5, b.getUtilise());
      preStat.setInt(6, b.getId());
      preStat.executeUpdate();
    } catch (SQLException ignore) {     
      System.out.println("erreur updateBon : " + ignore);
    }
    closeConnection(connex);
  }
View Full Code Here

     
     
      String query = "INSERT INTO product(Name, ModelNo, Price, Qty,description,categoryID) VALUES(?,?,?,?,?,?)";
      System.out.println("CategorycomboBox  : "+ CategorycomboBox.getSelectedItem());
      System.out.println("categoryMap  : "+ categoryMap.get(CategorycomboBox.getSelectedItem()));
      PreparedStatement ps = (PreparedStatement) con.prepareStatement(query);
      ps.setString(1, productnameTextField.getText());
      ps.setString(2, modelTextField.getText());
      ps.setString(3, priceTextField.getText());
      ps.setString(4, quantityTextField.getText());
      ps.setString(5, descriptionTextArea_1.getText());
      ps.setInt(6, categoryMap.get(CategorycomboBox.getSelectedItem()));
      System.out.println(ps);
      try{
        ps.executeUpdate();
      }catch(SQLException e){
        JOptionPane.showMessageDialog(null, "Please insert price and quantity properly",null, 0);
      }
     
     
View Full Code Here

      String query = "INSERT INTO product(Name, ModelNo, Price, Qty,description,categoryID) VALUES(?,?,?,?,?,?)";
     
      System.out.println("CategorycomboBox  : "+ CategorycomboBox.getSelectedItem());
      System.out.println("categoryMap  : "+ categoryMap.get(CategorycomboBox.getSelectedItem()));
     
      PreparedStatement ps = (PreparedStatement) con.prepareStatement(query);
      ps.setString(1, productnameTextField.getText());
      ps.setString(2, modelTextField.getText());
      ps.setString(3, priceTextField.getText());
      ps.setString(4, quantityTextField.getText());
      ps.setString(5, descriptionTextArea_1.getText());
      ps.setInt(6, categoryMap.get(CategorycomboBox.getSelectedItem()));
      System.out.println(ps);
      ps.executeUpdate();
      showResult();
      // conn.close();

    } catch (SQLException e) {
      e.printStackTrace();
View Full Code Here

TOP

Related Classes of com.mysql.jdbc.PreparedStatement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.