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

JDBC Java Discussion :

Connexion JDBC KO après huit heures de non connexion


Sujet :

JDBC Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Inscrit en
    Avril 2009
    Messages
    14
    Détails du profil
    Informations forums :
    Inscription : Avril 2009
    Messages : 14
    Par défaut Connexion JDBC KO après huit heures de non connexion
    Bonjour à tous,

    D'avance Merci à la personne qui me donnera un coup de main à ce souci récurent.

    En Fait chaque fois que je n'utilise pas mon appli pendant au moins 8H, les 2 premières connexions sont KO
    voici la trace:
    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
     
    /**********Début de la trace*****/
     
    type Rapport d'exception
     
    message
     
    description Le serveur a rencontr� une erreur interne () qui l'a emp�ch� de satisfaire la requ�te.
     
    exception
     
    org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.hibernate.exception.JDBCConnectionException: could not execute query
        org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:583)
        org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
     
    cause m�re
     
    org.hibernate.exception.JDBCConnectionException: could not execute query
        org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:74)
        org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
        org.hibernate.loader.Loader.doList(Loader.java:2216)
        org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
        org.hibernate.loader.Loader.list(Loader.java:2099)
        org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
        org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
        org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
        org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
        org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
        com.thalesgroup.SCPortal.common.dao.impl.IdentificationDaoImpl.getIdentificationByLoginAndPassword(IdentificationDaoImpl.java:46)
        com.thalesgroup.SCPortal.common.service.impl.ConnectionServiceImpl.getCollaborateurByIdentification(ConnectionServiceImpl.java:20)
        com.thalesgroup.SCPortal.common.controller.ConnectionUserController.handleRequest(ConnectionUserController.java:67)
        org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
        org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
        org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
        org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
        org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
     
    cause m�re
     
    com.mysql.jdbc.CommunicationsException: The last packet successfully received from the server was143659 seconds ago.The last packet sent successfully to the server was 143659 seconds ago, which  is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
        com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1070)
        com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3246)
        com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1917)
        com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060)
        com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542)
        com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734)
        com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1885)
        org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:93)
        org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
        org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
        org.hibernate.loader.Loader.doQuery(Loader.java:674)
        org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
        org.hibernate.loader.Loader.doList(Loader.java:2213)
        org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
        org.hibernate.loader.Loader.list(Loader.java:2099)
        org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
        org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
        org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
        org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
        org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
        com.thalesgroup.SCPortal.common.dao.impl.IdentificationDaoImpl.getIdentificationByLoginAndPassword(IdentificationDaoImpl.java:46)
        com.thalesgroup.SCPortal.common.service.impl.ConnectionServiceImpl.getCollaborateurByIdentification(ConnectionServiceImpl.java:20)
        com.thalesgroup.SCPortal.common.controller.ConnectionUserController.handleRequest(ConnectionUserController.java:67)
        org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
        org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
        org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
        org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
        org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
     
    cause m�re
     
    java.net.SocketException: Broken pipe
        java.net.SocketOutputStream.socketWrite0(Native Method)
        java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
        java.net.SocketOutputStream.write(SocketOutputStream.java:136)
        java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
        java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
        com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3227)
        com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1917)
        com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060)
        com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542)
        com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734)
        com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1885)
        org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:93)
        org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
        org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
        org.hibernate.loader.Loader.doQuery(Loader.java:674)
        org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
        org.hibernate.loader.Loader.doList(Loader.java:2213)
        org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
        org.hibernate.loader.Loader.list(Loader.java:2099)
        org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
        org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
        org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
        org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
        org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
        com.thalesgroup.SCPortal.common.dao.impl.IdentificationDaoImpl.getIdentificationByLoginAndPassword(IdentificationDaoImpl.java:46)
        com.thalesgroup.SCPortal.common.service.impl.ConnectionServiceImpl.getCollaborateurByIdentification(ConnectionServiceImpl.java:20)
        com.thalesgroup.SCPortal.common.controller.ConnectionUserController.handleRequest(ConnectionUserController.java:67)
        org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
        org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
        org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
        org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
        org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
     
     
    /*********Fin de la trace***/
    Dans mon fichier de configuration et de connexion à la base j'ai rajouté l'attribut "autoReconnect" que j'ai valorisé à vrai, malgré cela, rien ne marche.

    Ci-joint la partie qui du fichier context.xml relative à la connexion
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     
    <Resource name="jdbc/portailgestionprojetDB" auth="Container"
        type="javax.sql.DataSource" maxActive="100" maxIdle="30"
        maxWait="10000" username="userPortailDGI" password="passPortailDGI"
        driverClassName="com.mysql.jdbc.Driver"
        url="jdbc:mysql://localhost/portailgestionprojetdgi?autoReconnect=true&amp;useEncoding=true&amp;characterEncoding=UTF-8" />
     
        <Loader delegate="false" />
    Encore merci pour votre aide.

  2. #2
    Inactif  
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    2 189
    Détails du profil
    Informations personnelles :
    Âge : 45
    Localisation : Suisse

    Informations forums :
    Inscription : Mai 2006
    Messages : 2 189
    Par défaut
    hello,

    tout est dit ici

    com.mysql.jdbc.CommunicationsException: The last packet successfully received from the server was143659 seconds ago.The last packet sent successfully to the server was 143659 seconds ago, which is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.

  3. #3
    Membre averti
    Inscrit en
    Avril 2009
    Messages
    14
    Détails du profil
    Informations forums :
    Inscription : Avril 2009
    Messages : 14
    Par défaut
    Merci Alexandre pour ta réponse, cependant si tu regardes très bien le bout de code joint à ma note, tu t'apercevras que l'attribut "autoReconnect" est bien valorisé à true, mais malgré cela le plantage a toujours lieu.

    Pour info, j'utilise un fichier de config autre que celui d'hibernate. comment utiliser svp c3po dans un fichier context.xml défini comme suit:
    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
     
    <?xml version='1.0' encoding='UTF-8'?>
     
    <!-- The contents of this file will be loaded for each web application -->
    <Context path="/DBportailgestionprojet" docBase="DBportailgestionprojet"
        debug="5" reloadable="true" crossContext="true">
     
        <!-- maxActive: Maximum number of dB connections in pool. Make sure you
            configure your mysqld max_connections large enough to handle
            all of your db connections. Set to -1 for no limit.
        -->
     
        <!-- maxIdle: Maximum number of idle dB connections to retain in pool.
            Set to -1 for no limit.  See also the DBCP documentation on this
            and the minEvictableIdleTimeMillis configuration parameter.
        -->
     
        <!-- maxWait: Maximum time to wait for a dB connection to become available
            in ms, in this example 10 seconds. An Exception is thrown if
            this timeout is exceeded.  Set to -1 to wait indefinitely.
        -->
     
        <!-- username and password: MySQL dB username and password for dB connections  -->
     
        <!-- driverClassName: Class name for the old mm.mysql JDBC driver is
            org.gjt.mm.mysql.Driver - we recommend using Connector/J though.
            Class name for the official MySQL Connector/J driver is com.mysql.jdbc.Driver.
        -->
     
        <!-- url: The JDBC connection url for connecting to your MySQL dB.
            The autoReconnect=true argument to the url makes sure that the
            mm.mysql JDBC Driver will automatically reconnect if mysqld closed the
            connection.  mysqld by default closes idle connections after 8 hours.
        -->
     
        <Resource name="jdbc/portailgestionprojetDB" auth="Container"
            type="javax.sql.DataSource" maxActive="100" maxIdle="30"
            maxWait="10000" username="userPortailDGI" password="passPortailDGI"
            driverClassName="com.mysql.jdbc.Driver"
            url="jdbc:mysql://localhost/portailgestionprojetdgi?autoReconnect=true&amp;useEncoding=true&amp;characterEncoding=UTF-8" />
     
        <Loader delegate="false" />
    </Context>
    j'ai vu que dans le cas de hibernate.hbm.xml il fallait rajouter ceci
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     
    <!-- configuration pool via c3p0-->
            <property name="hibernate.c3p0.acquire_increment">1</property>
            <property name="hibernate.c3p0.idle_test_period">100</property><!-- seconds -->
            <property name="hibernate.c3p0.max_size">100</property><!-- Taille maximale du pool -->
            <property name="hibernate.c3p0.min_size">10</property><!-- Taille minimale du pool -->
            <property name="hibernate.c3p0.timeout">0</property><!-- seconds / 0 =jamais-->
            <property name="hibernate.c3p0.max_statements">0</property><!-- Taille du cache de statements de C3P0. 0 = désactive le cache -->
    plus le jar c3p0-0.9.1.2.jar dans le repertoire approprié!!! quelqu'un sait-il comment s'y prendre dans mon cas?

    Merci par avance

  4. #4
    Membre averti
    Inscrit en
    Avril 2009
    Messages
    14
    Détails du profil
    Informations forums :
    Inscription : Avril 2009
    Messages : 14
    Par défaut Re
    Bonjour de nouveau,

    Je dois peut être aux yeux de certains paraitre lourd, j'en suis désolé, je ne trouve toujours pas de solution à mon problème, quelqu'un aurait-il une petite idée?

  5. #5
    Membre éprouvé
    Avatar de _skip
    Homme Profil pro
    Développeur d'applications
    Inscrit en
    Novembre 2005
    Messages
    2 898
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : Suisse

    Informations professionnelles :
    Activité : Développeur d'applications
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Novembre 2005
    Messages : 2 898
    Par défaut
    Dans quelle logique crées-tu tes sessions? tu le fais à chaque opération? à chaque transaction ou une fois par application?

    Ton message me semble le genre de chose qui peut arriver quand on fait du session per application.

  6. #6
    Membre averti
    Inscrit en
    Avril 2009
    Messages
    14
    Détails du profil
    Informations forums :
    Inscription : Avril 2009
    Messages : 14
    Par défaut Re
    Je crée une session par transaction

  7. #7
    Membre à l'essai
    Profil pro
    Inscrit en
    Juin 2005
    Messages
    5
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2005
    Messages : 5
    Par défaut
    Bonjour,

    Etant confronté au même problème, je suis tombé sur un autre forum et j'ai trouvé ceci : http://www.kattare.com/forums/viewto...fedb67aace0c35

    A priori il s'agirait d'ajouter
    validationQuery="select 1"
    en attribut dans le "Ressource".

    Mais il faut tester et donc être très patient.

  8. #8
    Membre éclairé
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    511
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2006
    Messages : 511
    Par défaut
    Bonjour

    Mais il faut tester et donc être très patient.
    J'ai un peu le même Pb mais malgré le ping serveur "SELECT 1" OK, ma connexion à la bdd n'est pas valide car un SELECT * FROM t_login ne me retourne rien et du coups lance une vérification de l'intégrité de la bdd et donc si erreur, recrée aléatoirement n table (d'ou l'importance des sauvegardes).
    Ceci est provoqué suivant les remontées d'information que j'ai, à la première connexion du matin aléatoirement sur 4 serveurs. (Pool de connexion dbcp.BasicDataSources initialisé via un fichier properties)

Discussions similaires

  1. [2.2.2] Connexion JDBC non fermée
    Par satmbal dans le forum BIRT
    Réponses: 7
    Dernier message: 24/06/2008, 16h23
  2. Réponses: 1
    Dernier message: 12/04/2005, 20h36
  3. pool de connexion jdbc avec apache
    Par de LANFRANCHI dans le forum Oracle
    Réponses: 9
    Dernier message: 24/01/2005, 16h34
  4. [JDBC] manipulation des dates/heures en Java
    Par kurkLord dans le forum JDBC
    Réponses: 6
    Dernier message: 09/08/2004, 12h49
  5. connexion jdbc
    Par champion dans le forum PostgreSQL
    Réponses: 1
    Dernier message: 03/04/2004, 08h09

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