bonjour,
j'ai pas réussie à faire la connexion de sqlserver express avec eclipse
voici mon essai sachant que Server name : HP\SQLEXPRESS
Authentification : Windows Authentification
Code :
- private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) throws ClassNotFoundException {// GEN-FIRST:event_jButton3ActionPerformed
- lb4.setText("" );
- try {
- Class.forName ("com.microsoft.jdbc.sqlserver.SQLServerDriver" );
- Connection connection = DriverManager.getConnection("jdbc:sqlserver://localhost;databaseName=pfe;IntegratedSecurity=true;" );
- Statement st = connection.createStatement();
- String req = "select login , password from utilisateur";
- ResultSet rs = st.executeQuery(req);
- String log = tf1.getText();
- char[] pass = tf2.getPassword();
- while (rs.next()) {
- if ((log.equals(rs.getString("login" )))
- && (Arrays.equals(pass, rs.getString("password" )
- .toCharArray()))) {
- MainFrame mf = new MainFrame();
- mf.setLocationRelativeTo(null);
- mf.setVisible(true);
- dispose();
- } else {
- lb4.setText("Authentification echouée !!" );
- tf1.setText("" );
- tf2.setText("" );
- }
- }
- st.close();
- connection.close();
- } catch (SQLException sqle) {
- JOptionPane.showMessageDialog(null, "Connexion à la base echouée",
- "Erreur", JOptionPane.ERROR_MESSAGE);
- }
- }
|
voici le message d'erreur:
java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at GUI.Identification.jButton3ActionPerformed(Identification.java:173)
at GUI.Identification.access$3(Identification.java:167)
at GUI.Identification$4.actionPerformed(Identification.java:79)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
merci de m'aider SVP
Message édité par chimo01 le 30-05-2013 à 19:55:26