Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package sandwicherie;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.sql.Statement;
- import java.util.ArrayList;
- /**
- *
- * @author Mihaly
- */
- public final class Control{
- //variables d'instance
- Connection cnx;
- ResultSet rs;
- ArrayList<Client> clients= new ArrayList<Client>();
- ArrayList<Commande> commandes= new ArrayList<Commande>();
- Extrapolator extr= new Extrapolator();
- public Control() throws SQLException, ClassNotFoundException
- {
- connectOracle();
- //getListClient();
- getListCommandesEnAttante();
- deconnection();
- }
- public void connectOracle() throws SQLException, ClassNotFoundException
- {
- Class.forName("oracle.jdbc.OracleDriver");
- String connectStr = "jdbc:oracle:thin:I10050/9383@//172.16.130.8:1521/XE";
- cnx= DriverManager.getConnection(connectStr);
- }
- public void deconnection() throws SQLException
- {
- cnx.close();
- }
- public void getListClient() throws SQLException
- {
- clients.clear();
- getListClientPhysique();
- getListClientMorale();
- }
- public void getListClientPhysique()throws SQLException
- {
- 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 ";
- Statement stmt= cnx.createStatement();
- rs = stmt.executeQuery(querySelect);
- extr.extrClient(clients, rs);
- }
- public void getListClientMorale()throws SQLException
- {
- 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";
- Statement stmt= cnx.createStatement();
- rs = stmt.executeQuery(querySelect);
- extr.extrClient(clients, rs);
- }
- public void getListCommandesEnAttante() throws SQLException
- {
- 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";
- Statement stmt = cnx.createStatement();
- rs= stmt.executeQuery(querySelect);
- extr.extrListCommandesEnAttante(commandes, rs);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement