bjr,
jarrive pas pas a me connecter a la base de donnée sql
le message d'erreur est:
java.lang.NullPointerException
Metier.DAO.DAOUtilisateur.Authentifier(DAOUtilisateur.java:23)
Controleur.Authentification.processRequest(Authentification.java:43)
Controleur.Authentification.doGet(Authentification.java:63)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
------------------------------------------------------------------
dans la class DAOUtilisateur j'ai
------------------------------------------------------------------------
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 package Metier.DAO; import Metier.BO.Utilisateur; import Metier.Connexion; import java.sql.ResultSet; import java.sql.Statement; import java.sql.SQLException; / public class DAOUtilisateur implements IUtilisateur{ public boolean Authentifier(Utilisateur u) { try{ String sql="SELECT * FROM UTILISATEUR WHERE LOGIN='"+u.getLogin()+"' AND Password='"+u.getPassword()+"'"; Statement sc = Connexion.con.createStatement(); >>Ligne 23 ResultSet rs = sc.executeQuery(sql); return rs.next(); }catch(SQLException e){ e.printStackTrace(); return false; } } }
et dans la class Connexion:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package Metier.DAO; import java.sql.*; /** * * @author Mustapha */ public class Connexion { public static Connection con; private static Statement s; public static void Connect(){ if(con==null){ try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con =DriverManager.getConnection("jdbc:odbc:elearning"); }catch(ClassNotFoundException e){ e.printStackTrace(); } catch(SQLException e){ e.printStackTrace(); } } } public static Statement CreerStatement() { try{ s=con.createStatement();//creer un statement System.out.println("Statement créer"); return s; } catch(SQLException e4){ System.out.println(e4.getMessage()); return null; } } }
Merci de m'aider a resoudre mon probleme
Peace
Partager