Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package tp12;
- import java.beans.Statement;
- import java.io.BufferedReader;
- import java.io.FileReader;
- import java.io.IOException;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- import java.util.HashSet;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- /**
- *
- * @author sio
- */
- public class Restaurant_YUCAN2 extends javax.swing.JFrame {
- Connection con;
- Statement req;
- public Restaurant_YUCAN2() {
- initComponents();
- }
- /**
- * This method is called from within the constructor to initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is always
- * regenerated by the Form Editor.
- */
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">
- private void initComponents() {
- jLabel1 = new javax.swing.JLabel();
- jLabel2 = new javax.swing.JLabel();
- jLabel3 = new javax.swing.JLabel();
- jLabel4 = new javax.swing.JLabel();
- jLabel5 = new javax.swing.JLabel();
- jLabel6 = new javax.swing.JLabel();
- jLabel7 = new javax.swing.JLabel();
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- addWindowListener(new java.awt.event.WindowAdapter() {
- public void windowOpened(java.awt.event.WindowEvent evt) {
- formWindowOpened(evt);
- }
- });
- jLabel1.setText("Nom:");
- jLabel2.setText("Prenom:");
- jLabel3.setText("Adresse 1:");
- jLabel4.setText("Adresse 2:");
- jLabel5.setText("Code postal");
- jLabel6.setText("Ville:");
- jLabel7.setText("Note:");
- 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(53, 53, 53)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addComponent(jLabel3)
- .addGap(0, 0, Short.MAX_VALUE))
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jLabel2)
- .addComponent(jLabel1)
- .addComponent(jLabel7)
- .addComponent(jLabel5)
- .addComponent(jLabel4)
- .addComponent(jLabel6))
- .addContainerGap(378, Short.MAX_VALUE))))
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(29, 29, 29)
- .addComponent(jLabel1)
- .addGap(18, 18, 18)
- .addComponent(jLabel2)
- .addGap(18, 18, 18)
- .addComponent(jLabel3)
- .addGap(18, 18, 18)
- .addComponent(jLabel4)
- .addGap(18, 18, 18)
- .addComponent(jLabel5)
- .addGap(18, 18, 18)
- .addComponent(jLabel6)
- .addGap(18, 18, 18)
- .addComponent(jLabel7)
- .addContainerGap(51, Short.MAX_VALUE))
- );
- pack();
- }// </editor-fold>
- private void formWindowOpened(java.awt.event.WindowEvent evt) {
- try {
- //Chargement du pilote
- try {
- Class.forName("org.postgresql.Driver");
- } catch (ClassNotFoundException e) {
- System.out.println("Pilote mal installé ...");
- return;
- }
- try {
- //Connexion
- con = DriverManager.getConnection("jdbc:postgresql://sophie/dbaptista_restaurant",
- "dbaptista", "linux");
- } catch (SQLException ex) {
- Logger.getLogger(Restaurant_YUCAN2.class.getName()).log(Level.SEVERE, null, ex);
- }
- HashSet<Client> lesClients;
- lesClients = new HashSet<Client>();
- try {
- FileReader fclient = new FileReader("test.txt");
- BufferedReader liv = new BufferedReader(fclient);
- String ligne;
- ligne = liv.readLine();
- while (ligne != null) {
- String[] coupe = ligne.split(",");
- String nom = coupe[0];
- String prenom = coupe[1];
- String adr1 = coupe[2];
- String adr2 = coupe[3];
- String cp = coupe[4];
- String ville = coupe[5];
- String note = coupe[6];
- Client unClient = new Client(nom, prenom, adr1, adr2, cp, ville, note);
- lesClients.add(unClient);
- ligne = liv.readLine();
- }
- } catch (IOException ex) {
- Logger.getLogger(Restaurant_YUCAN2.class.getName()).log(Level.SEVERE, null, ex);
- }
- //Requête
- req = (Statement) con.createStatement();
- } catch (SQLException ex) {
- Logger.getLogger(Restaurant_YUCAN2.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- /**
- * @param args the command line arguments
- */
- public static void main(String args[]) {
- /* Set the Nimbus look and feel */
- //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
- /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
- * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
- */
- try {
- for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
- if ("Nimbus".equals(info.getName())) {
- javax.swing.UIManager.setLookAndFeel(info.getClassName());
- break;
- }
- }
- } catch (ClassNotFoundException ex) {
- java.util.logging.Logger.getLogger(Restaurant_YUCAN2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (InstantiationException ex) {
- java.util.logging.Logger.getLogger(Restaurant_YUCAN2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (IllegalAccessException ex) {
- java.util.logging.Logger.getLogger(Restaurant_YUCAN2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (javax.swing.UnsupportedLookAndFeelException ex) {
- java.util.logging.Logger.getLogger(Restaurant_YUCAN2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- //</editor-fold>
- /* Create and display the form */
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new Restaurant_YUCAN2().setVisible(true);
- }
- });
- }
- // Variables declaration - do not modify
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JLabel jLabel3;
- private javax.swing.JLabel jLabel4;
- private javax.swing.JLabel jLabel5;
- private javax.swing.JLabel jLabel6;
- private javax.swing.JLabel jLabel7;
- // End of variables declaration
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement