alors que sela ne marche pas.
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionpackage testa; import java.sql.*; import javax.swing.JDialog; public class B extends javax.swing.JDialog { public B(java.awt.Frame parent, boolean modal) { super(parent, modal); initComponents(); this.setLocationRelativeTo(null); this.setTitle("Authentification"); this.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); } @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { bindingGroup = new org.jdesktop.beansbinding.BindingGroup(); jPasswordField1 = new javax.swing.JPasswordField(); jButton1 = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jTextField2 = new javax.swing.JTextField(); jButton2 = new javax.swing.JButton(); jComboBox1 = new javax.swing.JComboBox(); jPasswordField2 = new javax.swing.JPasswordField(); jPasswordField1.setText("jPasswordField1"); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); jButton1.setText("Annuler"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jLabel1.setText("Service : "); jLabel2.setText("Ressource :"); jLabel3.setText("Passsword :"); jTextField2.setName("Login"); jTextField2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTextField2ActionPerformed(evt); } }); jButton2.setText("OK"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Reception", "Technique", "Validation", "Magasin", "Administrateur" })); org.jdesktop.beansbinding.ELProperty eLProperty = org.jdesktop.beansbinding.ELProperty.create("${toolTipText}"); org.jdesktop.swingbinding.JComboBoxBinding jComboBoxBinding = org.jdesktop.swingbinding.SwingBindings.createJComboBoxBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, jComboBox1, eLProperty, jComboBox1); bindingGroup.addBinding(jComboBoxBinding); jPasswordField2.setName("password"); jPasswordField2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jPasswordField2ActionPerformed(evt); } }); 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(19, 19, 19) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING)) .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(jTextField2, javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jComboBox1, 0, 202, Short.MAX_VALUE) .addComponent(jPasswordField2)) .addContainerGap(27, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(25, 25, 25) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2) .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3) .addComponent(jPasswordField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 21, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton1) .addComponent(jButton2)) .addGap(28, 28, 28)) ); bindingGroup.bind(); pack(); }// </editor-fold> private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { System.exit(0); } private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection( "Jdbc:Odbc:SAV1","",""); Statement s = con.createStatement(); ResultSet rs = s.executeQuery("SELECT * FROM user where Ressource='"+this.jTextField2.getText()+"'Pass='"+this.jPasswordField2.getPassword()+"'"); int count=0; while(rs.next()){ count += 1; } if(count == 1) { this.dispose(); } } catch (ClassNotFoundException | SQLException e) { System.out.println("Error: " + e); } } private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void jPasswordField2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { B dialog = new B(new javax.swing.JFrame(), true); dialog.addWindowListener(new java.awt.event.WindowAdapter() { @Override public void windowClosing(java.awt.event.WindowEvent e) { System.exit(0); } }); dialog.setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JComboBox jComboBox1; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JPasswordField jPasswordField1; private javax.swing.JPasswordField jPasswordField2; private javax.swing.JTextField jTextField2; private org.jdesktop.beansbinding.BindingGroup bindingGroup; // End of variables declaration }
ResultSet rs = s.executeQuery("SELECT * FROM user where Ressource='"+this.jTextField2.getText()+"'Pass='"+this.jPasswordField2.getPassword()+"'");
ResultSet rs = s.executeQuery("SELECT * FROM user where Ressource='"+this.jTextField2.getText()+" and 'Pass='"+this.jPasswordField2.getPassword()+"'");
Connection con = DriverManager.getConnection( "Jdbc:Odbc:SAV1", "","");
ResultSet rs = s.executeQuery("SELECT * FROM user where Ressource='"+this.jTextField2.getText()+")