diff --git a/GSBapplication/src/acces_aux_donnes/connexionSQL.java b/GSBapplication/src/acces_aux_donnes/connexionSQL.java
index 29d2e7c..53d58c2 100644
--- a/GSBapplication/src/acces_aux_donnes/connexionSQL.java
+++ b/GSBapplication/src/acces_aux_donnes/connexionSQL.java
@@ -1,13 +1,60 @@
-/*
- * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
- * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
- */
package acces_aux_donnes;
+/*
+Connexion.java
+Classe permettant d'établir une connexion avec une base de données mySQL
+*/
+import java.sql.Connection;
+import java.sql.DriverManager;
-/**
- *
- * @author emile.lalorcey
- */
public class connexionSQL {
-
+ private static Connection connect; // Variable de connexion
+
+ /**
+ * Constructeur
+ * @param serveur nom du serveur, localhost si local
+ * @param bdd nom de la base de données
+ * @param nomUtil nom utilisateur
+ * @param mdp mot de passe lié à l'utilisateur
+ */
+ private connexionSQL(String serveur, String bdd, String nomUtil, String mdp) {
+ try {
+ // 1. Chargement du driver
+ //Class.forName("com.mysql.jdbc.Driver");
+ Class.forName("com.mysql.cj.jdbc.Driver");
+ System.out.println("Driver accessible");
+
+ // 2. Initialisation des paramètres de connexion
+ String host = serveur; // Serveur de bd
+ String dbname = bdd; // Nom bd
+ String url = "jdbc:mysql://" + host + "/" + dbname; // url de connexion
+ System.out.println("url : "+url);
+ String user = nomUtil; // nom du user
+ System.out.println("nomUtil : "+nomUtil);
+ String passwd = mdp; // mot de passe
+ System.out.println("mdp : "+mdp);
+
+ // 3. Connexion
+ connect = (Connection) DriverManager.getConnection(url, user, passwd);
+ System.out.println("Connexion réussie !");
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Retourne la connection établie (Création d'une connection si elle n'existe pas)
+ * @param serveur nom du serveur, localhost si local
+ * @param bdd nom de la base de données
+ * @param nomUtil nom utilisateur
+ * @param mdp mot de passe lié à l'utilisateur
+ * @return connection établie
+ */
+ public static Connection getConnect(String serveur, String bdd, String nomUtil, String mdp) {
+ System.out.println("getConnect");
+ if (connect == null) {
+ new connexionSQL(serveur, bdd, nomUtil, mdp);
+ }
+ return connect;
+ }
}
diff --git a/GSBapplication/src/presentation/jffConnexion.form b/GSBapplication/src/presentation/jffConnexion.form
index 9b1d1b8..ba2353a 100644
--- a/GSBapplication/src/presentation/jffConnexion.form
+++ b/GSBapplication/src/presentation/jffConnexion.form
@@ -24,97 +24,147 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/GSBapplication/src/presentation/jffConnexion.java b/GSBapplication/src/presentation/jffConnexion.java
index d5224fa..ece65e6 100644
--- a/GSBapplication/src/presentation/jffConnexion.java
+++ b/GSBapplication/src/presentation/jffConnexion.java
@@ -26,17 +26,21 @@ public class jffConnexion extends javax.swing.JFrame {
// //GEN-BEGIN:initComponents
private void initComponents() {
- jLabel1 = new javax.swing.JLabel();
- jTFIdentifiant = new javax.swing.JTextField();
- jPFmdp = new javax.swing.JPasswordField();
- jBValider = new javax.swing.JButton();
- jBquitter = new javax.swing.JButton();
+ jPFond = new javax.swing.JPanel();
+ jLBonjour = new javax.swing.JLabel();
jLIdentifiant = new javax.swing.JLabel();
+ jTFIdentifiant = new javax.swing.JTextField();
jLmdp = new javax.swing.JLabel();
+ jPFmdp = new javax.swing.JPasswordField();
+ jBquitter = new javax.swing.JButton();
+ jBValider = new javax.swing.JButton();
+ jLLogo = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- jLabel1.setText("Bonjour veuillez vous identifier");
+ jLBonjour.setText("Bonjour veuillez vous identifier :");
+
+ jLIdentifiant.setText("Identifiant :");
jTFIdentifiant.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
@@ -44,59 +48,92 @@ public class jffConnexion extends javax.swing.JFrame {
}
});
- jPFmdp.setText("jPasswordField1");
+ jLmdp.setText("Mot de passe :");
- jBValider.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/valider.png"))); // NOI18N
- jBValider.setText("Valider");
+ jPFmdp.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jPFmdpActionPerformed(evt);
+ }
+ });
jBquitter.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/quitter.png"))); // NOI18N
jBquitter.setText("Quitter");
- jLIdentifiant.setText("Identifiant");
+ jBValider.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/valider.png"))); // NOI18N
+ jBValider.setText("Valider");
- jLmdp.setText("Mot de passe :");
+ jLLogo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/logodetoure.gif"))); // NOI18N
+
+ javax.swing.GroupLayout jPFondLayout = new javax.swing.GroupLayout(jPFond);
+ jPFond.setLayout(jPFondLayout);
+ jPFondLayout.setHorizontalGroup(
+ jPFondLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPFondLayout.createSequentialGroup()
+ .addGap(141, 141, 141)
+ .addComponent(jBquitter)
+ .addGap(18, 18, 18)
+ .addComponent(jBValider)
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addGroup(jPFondLayout.createSequentialGroup()
+ .addGap(109, 109, 109)
+ .addGroup(jPFondLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addGroup(jPFondLayout.createSequentialGroup()
+ .addComponent(jLBonjour)
+ .addGap(8, 8, 8))
+ .addGroup(jPFondLayout.createSequentialGroup()
+ .addGroup(jPFondLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPFondLayout.createSequentialGroup()
+ .addComponent(jLmdp, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
+ .addGroup(jPFondLayout.createSequentialGroup()
+ .addComponent(jLIdentifiant, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGap(19, 19, 19)))
+ .addGroup(jPFondLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
+ .addComponent(jTFIdentifiant, javax.swing.GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE)
+ .addComponent(jPFmdp))))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(jLLogo)
+ .addGap(26, 26, 26))
+ );
+ jPFondLayout.setVerticalGroup(
+ jPFondLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPFondLayout.createSequentialGroup()
+ .addGroup(jPFondLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPFondLayout.createSequentialGroup()
+ .addGap(30, 30, 30)
+ .addComponent(jLBonjour))
+ .addGroup(jPFondLayout.createSequentialGroup()
+ .addGap(17, 17, 17)
+ .addComponent(jLLogo)))
+ .addGap(29, 29, 29)
+ .addGroup(jPFondLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLIdentifiant)
+ .addComponent(jTFIdentifiant, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGap(34, 34, 34)
+ .addGroup(jPFondLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLmdp)
+ .addComponent(jPFmdp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 79, Short.MAX_VALUE)
+ .addGroup(jPFondLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jBquitter)
+ .addComponent(jBValider))
+ .addGap(45, 45, 45))
+ );
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
- .addGap(111, 111, 111)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addComponent(jBquitter)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(jBValider))
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
- .addGroup(layout.createSequentialGroup()
- .addComponent(jLIdentifiant, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addGap(18, 18, 18)
- .addComponent(jTFIdentifiant, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addComponent(jLabel1))
- .addGroup(layout.createSequentialGroup()
- .addComponent(jLmdp, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jPFmdp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
- .addContainerGap(102, Short.MAX_VALUE))
+ .addGap(23, 23, 23)
+ .addComponent(jPFond, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap(26, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(42, 42, 42)
- .addComponent(jLabel1)
- .addGap(32, 32, 32)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jTFIdentifiant, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jLIdentifiant))
- .addGap(27, 27, 27)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jPFmdp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jLmdp))
- .addGap(52, 52, 52)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jBValider)
- .addComponent(jBquitter))
- .addContainerGap(64, Short.MAX_VALUE))
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
+ .addGap(0, 6, Short.MAX_VALUE)
+ .addComponent(jPFond, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
pack();
@@ -106,6 +143,10 @@ public class jffConnexion extends javax.swing.JFrame {
// TODO add your handling code here:
}//GEN-LAST:event_jTFIdentifiantActionPerformed
+ private void jPFmdpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jPFmdpActionPerformed
+ // TODO add your handling code here:
+ }//GEN-LAST:event_jPFmdpActionPerformed
+
/**
* @param args the command line arguments
*/
@@ -144,10 +185,12 @@ public class jffConnexion extends javax.swing.JFrame {
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jBValider;
private javax.swing.JButton jBquitter;
+ private javax.swing.JLabel jLBonjour;
private javax.swing.JLabel jLIdentifiant;
- private javax.swing.JLabel jLabel1;
+ private javax.swing.JLabel jLLogo;
private javax.swing.JLabel jLmdp;
private javax.swing.JPasswordField jPFmdp;
+ private javax.swing.JPanel jPFond;
private javax.swing.JTextField jTFIdentifiant;
// End of variables declaration//GEN-END:variables
}