IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage Java Discussion :

utilisation d'une classe de connexion générique


Sujet :

Langage Java

  1. #1
    Membre régulier
    Profil pro
    Inscrit en
    Décembre 2007
    Messages
    150
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2007
    Messages : 150
    Points : 90
    Points
    90
    Par défaut utilisation d'une classe de connexion générique
    Bonjour tout le monde;

    Je développe une application Java avec MySQL.

    Je désire utiliser une classe de connexion générique, c'est à dire ne pas avoir à ecrire à chaque connexion toutes les lignes de codes de la connexion mais juste instancier la classe de connexion que j'ai appelée ConnectDB.

    Dans un autre fichier.java ou j'instancie cette classe pour faire un aller retour vers ma base de données, je fais qu'instancier un objet de la connexion comme convenu.

    Mais une erreur surgit : NullPointerException

    Merci pour votre patience et pour votre aide.

    Voici ma classe ConnetDB :

    ============>

    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
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
     
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
     
    package maquette_statique;
    import java.sql.*;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    /**
     *
     * @author lhabib
     */
    public class ConnectDB {
        ResultSet rs = null;
        Connection con = null;
        Statement stmt = null;
     
        public void connect(String queryString) {
            try {
    // ---- configure this for your site
                String username = "root";
                String password = "admin";
    // The URL that will connect to TECFA’s MySQL server
    // Syntax: jdbc:TYPE:machine:port/DB_NAME
                String url = "jdbc:mysql://localhost:3306/decompte";
    // A canned query string
                queryString = null;
    // ---- configure END
    // INSTALL/load the Driver (Vendor specific Code)
                try {
                    Class.forName("com.mysql.jdbc.Driver");
                } catch (java.lang.ClassNotFoundException e) {
                    System.err.print("ClassNotFoundException: ");
                    System.err.println(e.getMessage());
                }
     
    // Connection to the database at URL with usename and password
                con = DriverManager.getConnection(url, username, password);
                System.out.println("Ok, connection to the DB worked.");
                System.out.println("Let’s see can retrieve something with: " + queryString);
    // Create a Statement Object
                stmt = con.createStatement();
                // Send the query and bind to the result set
    	ResultSet rs = (ResultSet) stmt.executeQuery(queryString);
     
            } catch (SQLException ex) {
                Logger.getLogger(ConnectDB.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
    ***********************

    Remarquez que j'ai laissé en paramètre la requête sql qui dépend du fichier fichier qui instancie l'objet de connexion.

    ************************

    A présent voici mon fichier .java qui instancie la connexion ConnectDB :

    ==================>

    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
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
     
    package maquette_statique;
     
    import com.sun.rave.web.ui.appbase.AbstractPageBean;
    import com.sun.webui.jsf.component.Button;
    import com.sun.webui.jsf.component.Label;
    import com.sun.webui.jsf.component.TextField;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.faces.FacesException;
    import java.sql.*;
     
     
    public class Authentification extends AbstractPageBean {
     
    //ùùùùùùùùùùùùùùùùùùùùùùùùùùùùùù
     
        String email = new String();
        String password = new String();
     
        String loginBD = new String();
        String passwordBD = new String();
     
        ConnectDB connexion = new ConnectDB();
     
    //ùùùùùùùùùùùùùùùùùùùùùùùùùùùùùùùùùùùùùùùùùù    
     
        // <editor-fold defaultstate="collapsed" desc="Managed Component Definition">
     
        private void _init() throws Exception {
        }
        private TextField textField1 = new TextField();
     
        public TextField getTextField1() {
            return textField1;
        }
     
        public void setTextField1(TextField tf) {
            this.textField1 = tf;
        }
        private TextField textField2 = new TextField();
     
        public TextField getTextField2() {
            return textField2;
        }
     
        public void setTextField2(TextField tf) {
            this.textField2 = tf;
        }
        private Label label3 = new Label();
     
        public Label getLabel3() {
            return label3;
        }
     
        public void setLabel3(Label l) {
            this.label3 = l;
        }
     
        // </editor-fold>
     
        public Authentification() {
        }
     
        @Override
        public void init() {
            // Perform initializations inherited from our superclass
            super.init();
            // Perform application initialization that must complete
            // *before* managed components are initialized
            // TODO - add your own initialiation code here
     
            // <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
            // Initialize automatically managed components
            // *Note* - this logic should NOT be modified
            try {
                _init();
            } catch (Exception e) {
                log("Page1 Initialization Failure", e);
                throw e instanceof FacesException ? (FacesException) e: new FacesException(e);
            }
     
            // </editor-fold>
            // Perform application initialization that must complete
            // *after* managed components are initialized
            // TODO - add your own initialization code here
        }
     
        @Override
        public void preprocess() {
        }
        @Override
        public void prerender() {
        }
        @Override
        public void destroy() {
        }
     
      //ùùùùùùùùùùùùùùùùùùùùùùùùùùùùùùùùùùùùùù  
     
        public String button1_action() {
     
            try {
                String email = null;
                String password = null;
                String loginBD = null;
                String passwordBD = null;
     
                email = (String) textField1.getText();
                password = (String) textField2.getText();
     
     
                connexion.connect("select * from intervenant");
     
    /* =========> */           while (connexion.rs.next()) {
     
                    loginBD = connexion.rs.getString("login");
                    passwordBD = connexion.rs.getString("password");
     
                    if (email.equals(loginBD) && password.equals(passwordBD)) {
                        break;
                    }
                }
     
            } catch (SQLException ex) {
                Logger.getLogger(Authentification.class.getName()).log(Level.SEVERE, null, ex);
            }
     
            if (email.equals(loginBD) && password.equals(passwordBD)) {
                    return "case1";
                } else {
                    label3.setText("authentification invalide");
                    textField1.setText("");
                    textField2.setText("");
                    return null;
                }
     
     
        }
    //ùùùùùùùùùùùùùùùùùùùùùùùùùùùùùù
    }
    **************************************************

    Notez que les lignes de codes dont il s'agit sont encadrées par des

    //ùùùùùùùùùùùùùùùùùùùùùùùùùùùùùùù

    les autres sont a négliger.

    De plus le compilateur signale que l'erreur se situe au niveau de la ligne ou j'ai mis /* =========> */

  2. #2
    Membre régulier
    Profil pro
    Inscrit en
    Mai 2009
    Messages
    104
    Détails du profil
    Informations personnelles :
    Localisation : France, Puy de Dôme (Auvergne)

    Informations forums :
    Inscription : Mai 2009
    Messages : 104
    Points : 103
    Points
    103
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
     
    public String button1_action() {
     
    try {
    String email = null;
    String password = null;
    String loginBD = null;
    String passwordBD = null;
    Il n'y a aucun interêt à redéclarer des String alors que tu les as déjà déclaré en haut.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     
    String email = new String();
    String password = new String();
     
    String loginBD = new String();
    String passwordBD = new String();
     
    ConnectDB connexion = new ConnectDB();
    D'ailleurs tu pourrais directement les initialiser à null ici.

    C'est d'ailleurs d'ici que vient ton erreur.

    Toute variable déclarée dans un bloc (ici le bloc try/catch) est détruite à la sortie du bloc.

    Il se trouve qu'à la sortie du bloc tu fais appel à eux ici
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
    if (email.equals(loginBD) && password.equals(passwordBD)) {
    return "case1";
    } else {
    label3.setText("authentification invalide");
    textField1.setText("");
    textField2.setText("");
    return null;
    }
    Bref, vire les re-déclarations au début du bloc try/catch et ça devrait marcher.

  3. #3
    Membre régulier
    Profil pro
    Inscrit en
    Décembre 2007
    Messages
    150
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2007
    Messages : 150
    Points : 90
    Points
    90
    Par défaut
    Merci pour ton interêt;

    Je viens juste de faire ce que tu m'a dit, mais d'après ce que j'ai compris le compilateur me renvoye une exception dés lors qu'il pointe sur l'objet de la connexion c'est à dire cette ligne : connexion.rs.next() au niveau de la condition du while.

    Apparement il veut dire qu'il ne pointe sur rien, NullPointerException, et il faut songer à une autre manière de déclarer les choses.

    Merci encore

  4. #4
    Expert éminent sénior
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 482
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Points : 48 804
    Points
    48 804
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    ResultSet rs = (ResultSet) stmt.executeQuery(queryString);
    Avec ça, tu défini un variable locale à ta méthode connect, qui n'a rien a voir avec le champ de l'objet ConnectDB, chanmp que tu utilise dans ton while.

  5. #5
    Membre régulier
    Profil pro
    Inscrit en
    Décembre 2007
    Messages
    150
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2007
    Messages : 150
    Points : 90
    Points
    90
    Par défaut
    J'ai essayer ce que vous m'avez dit mais ca ne marche.

    Voici mon code:

    Ma classe de 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
    package statiquement;
    import java.sql.*;
    import java.util.logging.Level;
    import java.util.logging.Logger;
     
    public class ConnectDB {
       public ResultSet rs = null;
       public Connection con = null;
       public Statement stmt = null;
     
        public void connect(String queryString) {
     
            try {
     
               String username = "root";
                String password = "admin";
     
                String url = "jdbc:mysql://localhost:3306/decompte";
     
                queryString = null;
     
                            try {
                                Class.forName("com.mysql.jdbc.Driver");
                            } catch (java.lang.ClassNotFoundException e) {
                                System.err.print("ClassNotFoundException: ");
                                System.err.println(e.getMessage());
                            }
     
                con = DriverManager.getConnection(url, username, password);
                System.out.println("Ok, connection to the DB worked.");
                System.out.println("Let’s see can retrieve something with: " + queryString);
     
                stmt = con.createStatement();
     
    	 rs = (ResultSet) stmt.executeQuery(queryString);
     
            } // fin du 1er try
                    catch (SQLException ex) {
                        Logger.getLogger(ConnectDB.class.getName()).log(Level.SEVERE, null, ex);
                    }
        } // fin de la fonction connect
    }//fin de la classe
    **************************************

    Et maintenant voici mon bean, avec une methode action d'un bouton :


    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
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    package statiquement;
     
    import com.sun.rave.web.ui.appbase.AbstractPageBean;
    import com.sun.webui.jsf.component.Button;
    import com.sun.webui.jsf.component.Label;
    import com.sun.webui.jsf.component.TextField;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.faces.FacesException;
    import java.sql.*;
     
     
    public class Page1 extends ConnectDB  {
     
        String log = null;
        String pass = null;
     
        String s = null;
        String n = null;
     
        Connection con = null;
    	Statement stmt = null;
     
        ConnectDB connexion = new ConnectDB();
     
     
        private void _init() throws Exception {
        }
        private TextField textField2 = new TextField();
     
        public TextField getTextField2() {
            return textField2;
        }
     
        public void setTextField2(TextField tf) {
            this.textField2 = tf;
        }
        private TextField textField1 = new TextField();
     
        public TextField getTextField1() {
            return textField1;
        }
     
        public void setTextField1(TextField tf) {
            this.textField1 = tf;
        }
        private Button button1 = new Button();
     
        public Button getButton1() {
            return button1;
        }
     
        public void setButton1(Button b) {
            this.button1 = b;
        }
        private Label label3 = new Label();
     
        public Label getLabel3() {
            return label3;
        }
     
        public void setLabel3(Label l) {
            this.label3 = l;
        }
     
        public Page1() {
      }
     
        public String button1_action() {
     
            try {
                log = (String) textField1.getText();
                pass = (String) textField2.getText();
     
                ConnectDB connexion = new ConnectDB();
                connexion.connect("select * from intervenant");
     
                while (connexion.rs.next()) {
                    s = rs.getString("login");
                    n = rs.getString("password");
                }
                // Close resources
                stmt.close();
                con.close();
    // print out decent error messages
     
            } catch(SQLException ex) {
    System.err.println("==> SQLException: ");
     
    while (ex != null)
    {
    System.out.println("Message: " + ex.getMessage ());
    System.out.println("SQLState: " + ex.getSQLState ());
    System.out.println("ErrorCode: " + ex.getErrorCode ());
    ex = ex.getNextException();
    System.out.println("");
    }
    }
     
    // print out decent error messages
    if(log.equals(s) && pass.equals(n))
                label3.setText("authentification réussie");
            else
                label3.setText("authentification failed, réessayer");
            return null;
        }
     
    }
    ************************************

    l'erreur se situe toujours au niveau du while du bean, NullPointerException.

    MERCI POUR VOTRE PATIENCE.

  6. #6
    Expert éminent sénior
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 482
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Points : 48 804
    Points
    48 804
    Par défaut
    si rs est toujours null, c'est que tu as eu une exception dans ta classe de connection, faut regarder les logs pour savoir quelle est l'erreur.

  7. #7
    Membre régulier
    Profil pro
    Inscrit en
    Décembre 2007
    Messages
    150
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2007
    Messages : 150
    Points : 90
    Points
    90
    Par défaut
    Bonjour;
    Que voulez-vous dire par les logs,

    si c'est la trace de la pile d'erreur, je n'y comprends que NUllPointerException car les classes qui restent relèvent du niveau de la recherche informatique lol

  8. #8
    Membre habitué
    Profil pro
    Inscrit en
    Février 2005
    Messages
    119
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2005
    Messages : 119
    Points : 192
    Points
    192
    Par défaut
    Si tu pouvais copier ici la pile d'exception que tu obtiens, ça aiderais sûrement.

  9. #9
    Expert éminent sénior
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 482
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Points : 48 804
    Points
    48 804
    Par défaut
    Je parle notement de ce log là qui doit bien arriver quelque part, car ce SQLException est la raison pour laquelle ton rs est null.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
                    catch (SQLException ex) {
                        Logger.getLogger(ConnectDB.class.getName()).log(Level.SEVERE, null, ex);
                    }

  10. #10
    Membre régulier
    Profil pro
    Inscrit en
    Décembre 2007
    Messages
    150
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2007
    Messages : 150
    Points : 90
    Points
    90
    Par défaut
    je ne crois pas que ce soit le log qui provoque l'exception car SQLException n'apparait nulle part dans la pile d'erreur.

    Statiquement est mon package, Page1 la page jsp, button1_action la methode dans le bean

    =======>


    statiquement.Page1.button1_action(Page1.java:78)
    sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-2)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    com.sun.el.parser.AstValue.invoke(AstValue.java:187)
    com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
    javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:77)
    com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
    com.sun.rave.web.ui.appbase.faces.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
    javax.faces.component.UICommand.broadcast(UICommand.java:383)
    com.sun.webui.jsf.component.WebuiCommand.broadcast(WebuiCommand.java:160)
    javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:447)
    javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:752)
    com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
    com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
    com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
    com.sun.faces.extensions.avatar.lifecycle.PartialTraversalLifecycle.execute(PartialTraversalLifecycle.java:94)
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
    org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:333)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    com.sun.webui.jsf.util.UploadFilter.doFilter(UploadFilter.java:267)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:313)
    org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:287)
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:218)
    org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
    org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
    com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
    com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:98)
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:222)
    org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
    org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
    org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096)
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:166)
    org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
    org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
    org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096)
    org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:288)
    com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:647)
    com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:579)
    com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:831)
    com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
    com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
    com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
    com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
    com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)

  11. #11
    Expert éminent sénior
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 482
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Points : 48 804
    Points
    48 804
    Par défaut
    Citation Envoyé par twister9458 Voir le message
    je ne crois pas que ce soit le log qui provoque l'exception car SQLException n'apparait nulle part dans la pile d'erreur.

    Le log ne provoque pas d'erreur (encore heureux tiens), et, forcément, ta SQLException n'apparait pas dans la trace puisque tu l'a déjà traitée (en la logguant) d'ou l'intéret d'aller voir dans le log quelle est cette exception.

    Parce que ce qui se passe est çà

    connect -> SQLException -> log -> sortie de connect sans avoir initialisé rs -> suite de la jsp -> appel à rs -> NullPointerException -> affichage du NullPointerException dans la page.

  12. #12
    Membre régulier
    Profil pro
    Inscrit en
    Décembre 2007
    Messages
    150
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2007
    Messages : 150
    Points : 90
    Points
    90
    Par défaut
    Bonjour;

    En effet tchize vous avez raison la requete String ne passe pas, et le compilateur ne retient que la valeur null, d'ou null pointer exception

    Je pars corriger l'erreur et vous rends compte

    Merci

  13. #13
    Membre régulier
    Profil pro
    Inscrit en
    Décembre 2007
    Messages
    150
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2007
    Messages : 150
    Points : 90
    Points
    90
    Par défaut
    oooleeeeee ca marche enfin, merci beaucoup les gars et merci à vous tchize qui avez su ou est l'erreur

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Utilisation d'une classe connexion pour MySQL
    Par nolookpass8 dans le forum Développement Web en Java
    Réponses: 7
    Dernier message: 02/04/2013, 17h42
  2. Réponses: 2
    Dernier message: 20/01/2012, 16h02
  3. Utiliser une classe de connexion SMTP
    Par adrien555 dans le forum Général Conception Web
    Réponses: 0
    Dernier message: 27/08/2010, 10h30
  4. Utilisation d'une classe générique
    Par bandit_debutant dans le forum Langage
    Réponses: 4
    Dernier message: 06/12/2006, 16h54
  5. Réponses: 2
    Dernier message: 18/05/2004, 14h12

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo