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

Tomcat et TomEE Java Discussion :

[Tomcat 5.5] Pool de connexion


Sujet :

Tomcat et TomEE Java

  1. #1
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Mai 2005
    Messages
    41
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2005
    Messages : 41
    Points : 32
    Points
    32
    Par défaut [Tomcat 5.5] Pool de connexion
    Bonsoir,

    J'ai un petit problème avec un pool de connexion sous tomcat 5.5.
    J'ai renseigné le fichier context.xml de l'application avec les renseignements suivants :

    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
    <?xml version="1.0" encoding="UTF-8"?>
    <Context path="/mypictures">
     
      <Resource 
        auth="Container" 
        driverClassName="com.mysql.jdbc.Driver" 
        logAbandoned="true" 
        maxActive="100" 
        maxIdle="30" 
        maxWait="10000" 
        name="jdbc/WebNativeLocalHost" 
        password="********" 
        removeAbandoned="true" 
        removeAbandonedTimeout="300" 
        type="javax.sql.DataSource" 
        url="jdbc:mysql://127.0.0.1:3306/webnative" 
        validationQuery="SELECT 1" 
        testOnBorrow="true" 
        username="ftpserver" 
      />
      <Resource 
        auth="Container" 
        driverClassName="com.mysql.jdbc.Driver" 
        logAbandoned="true" 
        maxActive="8" 
        maxIdle="8" 
        maxWait="10000" 
        name="jdbc/DiorThequeLocalHost" 
        password="********" 
        removeAbandoned="true" 
        removeAbandonedTimeout="300" 
        type="javax.sql.DataSource" 
        url="jdbc:mysql://127.0.0.1:3306/diortheque" 
        validationQuery="SELECT 1" 
        testOnBorrow="true" 
        username="ftpserver" 
      />
      <Resource 
        auth="Container" 
        driverClassName="com.mysql.jdbc.Driver" 
        logAbandoned="true" 
        maxActive="8" 
        maxIdle="8" 
        maxWait="10000" 
        name="jdbc/WebNativeFP" 
        password="**********" 
        removeAbandoned="true" 
        removeAbandonedTimeout="300" 
        type="javax.sql.DataSource" 
        url="jdbc:mysql://192.168.4.250:3306/webnative" 
        validationQuery="SELECT 1" 
        testOnBorrow="true" 
        username="diorthequeadmin" 
      />
    </Context>
    Tout fonctionne correctement, mais j'ai un problème avec cela :

    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
     public void insertHitsid(String login, String xmldbid){
     
            Connection connect = null;
            Statement stat = null;
            String SQL2 = "INSERT INTO hits (login,xmldbid,hits) VALUES ('"+login+"','"+xmldbid+"','0')";
            try {
                accessdb.getDt().getConnection();
     
                stat = connect.createStatement();
                stat.executeUpdate(SQL2);
     
     
            } catch (SQLException ex) {
                ex.printStackTrace();
                logueur.warn(ex.getMessage());
            }finally{
                if(stat != null){
                    try {
                        stat.close();
                    } catch (SQLException ex) {
                        ex.printStackTrace();
                        logueur.warn(ex.getMessage());
                    }
                    stat=null;
                }
                if(connect != null){
                    try {
                        connect.close();
                    } catch (SQLException ex) {
                        ex.printStackTrace();
                        logueur.warn(ex.getMessage());
                    }
                    connect=null;
                }
            }
        }
    les fichiers log de tomcat m'indique l'erreur suivante :

    2008-06-24 19:18:01 ERROR http-8080-Processor21 org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/mypictures].[myPhotothequeControleur] - "Servlet.service()" pour la servlet myPhotothequeControleur a g?n?r? une exception
    java.lang.NullPointerException
    at com.maison.myphototheque.metier.myPhotothequeDAO.insertHitsid(myPhotothequeDAO.java:1177)
    at com.maison.myphototheque.metier.myPhotothequeDAO.addUser(myPhotothequeDAO.java:981)
    at com.maison.myphototheque.metier.myPhotothequeBusinessFacade.addUser(myPhotothequeBusinessFacade.java:72)
    at com.maison.myphototheque.beans.myPhotothequeBusinessDelegate.addUser(myPhotothequeBusinessDelegate.java:69)
    at com.maison.myphototheque.servlets.myPhotothequeControleur.service(myPhotothequeControleur.java:348)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
    at java.lang.Thread.run(Thread.java:613)
    la ligne 1177 correspondant à :

    stat = connect.createStatement();

    Je ne comprend pas, car par ailleurs dans le même fichier je fais un update avec la même configuration et cela fonctionne .....

    Quelqu'un a-t-il une petite idée ????

    Merci

    Jean-Pierre

  2. #2
    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
    1
    2
    3
    4
    5
    6
    7
    Connection connect = null;
    Statement stat = null;
    String SQL2 = "INSERT INTO hits (login,xmldbid,hits) VALUES ('"+login+"','"+xmldbid+"','0')";
    try {
    accessdb.getDt().getConnection();
    
    stat = connect.createStatement();
    A priori, normal qu'il soit null, tu ne lui attribue pas d'autre valeur!

  3. #3
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Mai 2005
    Messages
    41
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2005
    Messages : 41
    Points : 32
    Points
    32
    Par défaut
    Citation Envoyé par tchize_ Voir le message
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    Connection connect = null;
    Statement stat = null;
    String SQL2 = "INSERT INTO hits (login,xmldbid,hits) VALUES ('"+login+"','"+xmldbid+"','0')";
    try {
    accessdb.getDt().getConnection();
    
    stat = connect.createStatement();
    A priori, normal qu'il soit null, tu ne lui attribue pas d'autre valeur!
    Désolé, je ne comprend pas la réponse !
    Un petit exemple pour me donner un début de solution ?

  4. #4
    Modérateur
    Avatar de OButterlin
    Homme Profil pro
    Inscrit en
    Novembre 2006
    Messages
    7 313
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 7 313
    Points : 9 529
    Points
    9 529
    Billets dans le blog
    1
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    ...
    try
    {
       connect = accesdb.getDt().getConnection();
    ...
    Dans ton cas, la connection est NULL (puisque non affectée) d'où l'erreur NullPointerException à la ligne connect.createStatement()

    A+

  5. #5
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Mai 2005
    Messages
    41
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2005
    Messages : 41
    Points : 32
    Points
    32
    Par défaut
    Heu, je crois que dans le cas présent, ce n'est pas la connexion qui est "NULL" mais bien moi !!!!

    Comment n'ai-je pas vu que je n'avais pas initialisé la connexion ???? (fatigue, besoin de vacances ...)

    En tout cas merci à tous les deux d'avoir tout de même répondu à ma question.

    JPA

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

Discussions similaires

  1. [Tomcat] Problème du pooling de connexion
    Par divail dans le forum Tomcat et TomEE
    Réponses: 2
    Dernier message: 27/07/2006, 14h27
  2. Réponses: 8
    Dernier message: 26/07/2006, 12h02
  3. [Tomcat 5.0] pool de connexion
    Par helter_skelter dans le forum Tomcat et TomEE
    Réponses: 14
    Dernier message: 21/06/2006, 10h50
  4. [Tomcat 5.5] Pool de connexion très lent
    Par JFDelges dans le forum Tomcat et TomEE
    Réponses: 9
    Dernier message: 14/10/2005, 13h44
  5. [TOMCAT] Ressource globale pool de connexion partagée
    Par ren0 dans le forum Tomcat et TomEE
    Réponses: 5
    Dernier message: 15/03/2005, 14h05

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