Advertisement
Guest User

Untitled

a guest
Aug 13th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.60 KB | None | 0 0
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5.  
  6. package sandwicherie;
  7.  
  8. import java.sql.Connection;
  9. import java.sql.DriverManager;
  10. import java.sql.ResultSet;
  11. import java.sql.SQLException;
  12. import java.sql.Statement;
  13. import java.util.ArrayList;
  14.  
  15.  
  16. /**
  17.  *
  18.  * @author Mihaly
  19.  */
  20. public final class Control{
  21. //variables d'instance
  22.    
  23.     Connection cnx;
  24.     ResultSet rs;
  25.     ArrayList<Client> clients= new ArrayList<Client>();
  26.     ArrayList<Commande> commandes= new ArrayList<Commande>();
  27.    
  28.    Extrapolator extr= new Extrapolator();
  29.    
  30.    
  31.    public Control() throws SQLException, ClassNotFoundException
  32.    {
  33.        connectOracle();
  34.        //getListClient();
  35.        getListCommandesEnAttante();
  36.        
  37.        deconnection();
  38.        
  39.    }
  40.    
  41.    
  42.  
  43.    
  44.  
  45.     public void connectOracle() throws SQLException, ClassNotFoundException
  46.     {
  47.         Class.forName("oracle.jdbc.OracleDriver");
  48.        
  49.  
  50.         String connectStr = "jdbc:oracle:thin:I10050/9383@//172.16.130.8:1521/XE";
  51.         cnx= DriverManager.getConnection(connectStr);
  52.     }
  53.     public void deconnection() throws SQLException
  54.     {
  55.         cnx.close();
  56.     }
  57.    
  58. public void getListClient() throws SQLException
  59.     {
  60.         clients.clear();
  61.         getListClientPhysique();
  62.  
  63.         getListClientMorale();
  64.  
  65.  
  66.  
  67.     }
  68. public void getListClientPhysique()throws SQLException
  69. {
  70.      String querySelect = "SELECT c.NOM, c.ADRESSE, c.Identifiant, c.motdepasse, c.mail, c.numpersonne, c.numentreprise, p.dateanniversaire, p.bonusfrequentation FROM client c JOIN Personne p ON p.numPersonne = c.numPersonne ";
  71.      Statement stmt= cnx.createStatement();
  72.  
  73.      rs = stmt.executeQuery(querySelect);
  74.  
  75.      extr.extrClient(clients, rs);
  76.  
  77. }
  78.  
  79. public void getListClientMorale()throws SQLException
  80. {
  81.  
  82.  
  83.          String querySelect = "Select c.NOM, c.ADRESSE, c.Identifiant, c.motdepasse, c.mail, e.numTVA, e.numCompte, c.numpersonne, c.numentreprise From client c JOIN Entreprise e ON e.numEntreprise = c.numEntreprise";
  84.          Statement stmt= cnx.createStatement();
  85.  
  86.          rs = stmt.executeQuery(querySelect);
  87.  
  88.              extr.extrClient(clients, rs);
  89. }
  90.  
  91. public void getListCommandesEnAttante() throws SQLException
  92. {
  93.  
  94.     String querySelect= "SELECT co.etat, cl.identifiant, co.emporter, co.etat, co.numClient FROM Commande co JOIN Client cl ON co.numclient = cl.numclient WHERE CO.ETAT = 1";
  95.     Statement stmt = cnx.createStatement();
  96.  
  97.     rs= stmt.executeQuery(querySelect);
  98.  
  99.     extr.extrListCommandesEnAttante(commandes, rs);
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106. }
  107.  
  108.  
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement