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

Requêtes MySQL Discussion :

Requetes de l'extérieur sur serveur distant


Sujet :

Requêtes MySQL

  1. #1
    Membre à l'essai
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    26
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2006
    Messages : 26
    Points : 23
    Points
    23
    Par défaut Requetes de l'extérieur sur serveur distant
    Bonjour, j'ai une petite application JAVA (avec interface graphique) qui exécute des requetes SQL sur une base de données (MySQL/EasyPhp/PhpMyAdmin), lorsque j'exécute mon application sur le poste contenant la base de données (le serveur) tout marche bien , mais quand j'essaye de lancer mon appli sur un autre ordi, j'ai un message comme quoi je peu pas exécuter de requêtes sur la base de données (j'ai vérifié le login et pass => tout est correct).

    Est ce que vous connaissez un moyen d'executer des requetes sql sur un autre poste que celui "SERVEUR" ?

    Merci d'avance

  2. #2
    Expert éminent
    Avatar de Swoög
    Profil pro
    Inscrit en
    Janvier 2003
    Messages
    6 045
    Détails du profil
    Informations personnelles :
    Âge : 37
    Localisation : France

    Informations forums :
    Inscription : Janvier 2003
    Messages : 6 045
    Points : 8 339
    Points
    8 339
    Par défaut
    Salut !

    J'ai peur que ça ne concerne principalement JAVA

    Serait-il possible de voir comment tu te conectes à la base de données ?
    (remplace le nom d'utilisateur par USER et le mot de passe par PASS )

    Est-ce que MySQL est bien configuré pour répondre à toutes les connections ? (bind-addresse à 0.0.0.0 dans my.ini je crois)

    Tu n'aurais pas de par-feu qui bloque les connections ? de routeur entre les deux PCs etc ... ?

  3. #3
    Membre à l'essai
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    26
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2006
    Messages : 26
    Points : 23
    Points
    23
    Par défaut
    Je viens juste de modifier le bind-addresse à 0.0.0.0 (avant c'était 127.0.0.1), mais j'ai toujours le même problème
    Voici les paramètres que j'utilise pour ma connection à la base de données (sur le serveur et également sur le poste client) :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    user=root
    password=
    url=jdbc\:mysql\://localhost/java
    driver=com.mysql.jdbc.Driver
    Voici ma méthode pour initialiser la connexion (elle marche très bien sur le poste "SERVEUR") :

    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
    public void initialiserConnexion(String fichierConfig) throws Exception
          {
                  /*Création d'un objet de type Properties (package java.util)où seront mémorisés 
                  les données relatifs à la connexion de la base de données*/    
                Properties propBD = new Properties();
     
                /*Création d'un Flux d'entrée pour la lecture du fichier contenant 
                 la config. de la base de données*/
                FileInputStream entree = null;
                try
                {
                  entree = new FileInputStream(fichierConfig);
                  propBD.load(entree);  
                }
                finally
                {
                  entree.close();
                }
     
                //Initialisation de la classe faisant référence au Driver de la BDD
                Class.forName(propBD.getProperty("driver"));
     
                //Connexion à la BDD avec les paramètres du fichier de configuration
                conn = DriverManager.getConnection(propBD.getProperty("url"),
                propBD.getProperty("user"),propBD.getProperty("password"));
          }
    Voici l'erreur que j'ai sur le poste client :
    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
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
     
    C:\Program Files\Java\jre1.5.0_06\bin>java -jar images.jar
    Debut de l'execution du programme
    com.mysql.jdbc.CommunicationsException: Communications link failure due to under
    lying exception:
     
    ** BEGIN NESTED EXCEPTION **
     
    java.net.SocketException
    MESSAGE: java.net.ConnectException: Connection refused: connect
     
    STACKTRACE:
     
    java.net.SocketException: java.net.ConnectException: Connection refused: connect
     
            at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.ja
    va:156)
            at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:284)
            at com.mysql.jdbc.Connection.createNewIO(Connection.java:2555)
            at com.mysql.jdbc.Connection.<init>(Connection.java:1485)
            at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java
    :266)
            at java.sql.DriverManager.getConnection(Unknown Source)
            at java.sql.DriverManager.getConnection(Unknown Source)
            at images.Bdd.initialiserConnexion(bdd.java:48)
            at images.JDBC_Blob$2.actionPerformed(JDBC_BlobNew.java:126)
            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.AbstractButton.doClick(Unknown Source)
            at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
            at javax.swing.plaf.basic.BasicMenuItemUI$Handler.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.dispatchEvent(Unknown Source)
            at java.awt.EventDispatchThread.pumpOneEventForHierarchy(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)
     
    ** END NESTED EXCEPTION **
     
    Last packet sent to the server was 16 ms ago.
            at com.mysql.jdbc.Connection.createNewIO(Connection.java:2621)
            at com.mysql.jdbc.Connection.<init>(Connection.java:1485)
            at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java
    :266)
            at java.sql.DriverManager.getConnection(Unknown Source)
            at java.sql.DriverManager.getConnection(Unknown Source)
            at images.Bdd.initialiserConnexion(bdd.java:48)
            at images.JDBC_Blob$2.actionPerformed(JDBC_BlobNew.java:126)
            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.AbstractButton.doClick(Unknown Source)
            at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
            at javax.swing.plaf.basic.BasicMenuItemUI$Handler.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.dispatchEvent(Unknown Source)
            at java.awt.EventDispatchThread.pumpOneEventForHierarchy(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)
    com.mysql.jdbc.CommunicationsException: Communications link failure due to under
    lying exception:
     
    ** BEGIN NESTED EXCEPTION **
     
    java.net.SocketException
    MESSAGE: java.net.ConnectException: Connection refused: connect
     
    STACKTRACE:
     
    java.net.SocketException: java.net.ConnectException: Connection refused: connect
     
            at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.ja
    va:156)
            at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:284)
            at com.mysql.jdbc.Connection.createNewIO(Connection.java:2555)
            at com.mysql.jdbc.Connection.<init>(Connection.java:1485)
            at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java
    :266)
            at java.sql.DriverManager.getConnection(Unknown Source)
            at java.sql.DriverManager.getConnection(Unknown Source)
            at images.Bdd.initialiserConnexion(bdd.java:48)
            at images.JDBC_Blob$2.actionPerformed(JDBC_BlobNew.java:126)
            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.AbstractButton.doClick(Unknown Source)
            at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
            at javax.swing.plaf.basic.BasicMenuItemUI$Handler.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.dispatchEvent(Unknown Source)
            at java.awt.EventDispatchThread.pumpOneEventForHierarchy(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)
     
     
    ** END NESTED EXCEPTION **
     
     
     
    Last packet sent to the server was 0 ms ago.
            at com.mysql.jdbc.Connection.createNewIO(Connection.java:2621)
            at com.mysql.jdbc.Connection.<init>(Connection.java:1485)
            at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java
    :266)
            at java.sql.DriverManager.getConnection(Unknown Source)
            at java.sql.DriverManager.getConnection(Unknown Source)
            at images.Bdd.initialiserConnexion(bdd.java:48)
            at images.JDBC_Blob$2.actionPerformed(JDBC_BlobNew.java:126)
            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.AbstractButton.doClick(Unknown Source)
            at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
            at javax.swing.plaf.basic.BasicMenuItemUI$Handler.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.dispatchEvent(Unknown Source)
            at java.awt.EventDispatchThread.pumpOneEventForHierarchy(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)

  4. #4
    Expert éminent
    Avatar de Swoög
    Profil pro
    Inscrit en
    Janvier 2003
    Messages
    6 045
    Détails du profil
    Informations personnelles :
    Âge : 37
    Localisation : France

    Informations forums :
    Inscription : Janvier 2003
    Messages : 6 045
    Points : 8 339
    Points
    8 339
    Par défaut


    Comme je m'en doutais :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    url=jdbc\:mysql\://localhost/java
    + le bind (grand classique avec les serveurs packagés ^^)

    il ne faut pas que tu utilise localhost pour le post client, car il essaie alors de se connecter à lui-même, il faut que tu mettes soit l'IP du serveur qui héberge MySQL, soit un nom de domaine qui permette d'y accèder (après avoir modifier le bind dans le my.ini, tu as bien pensé à redémarrer MySQL ? )

  5. #5
    Membre à l'essai
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    26
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2006
    Messages : 26
    Points : 23
    Points
    23
    Par défaut
    J'ai fait la dernière modif, maintenant j'arrive presque à me connecter à la base de données MySql mais quand je me connecte j'ai un message d'erreur : Error 1130 Le Hôte Fran-WinXP n'est pas autorisé à se connecter à ce serveur MySQL (je viens d'installer un analyseur de requêtes pour faire des tests et voir si la connection à la BDD MySQL marche correctement).
    Je penses qu'il faut définir des permissions dans phpMyAdmin/MySQL mais là vraiment je sais pas comment faire.
    J'ai fait un petit grant pour mon ip et un nouvel utilisateur, maintenant tout marche bien (j'ai quand même mis 1h avant de trouver qu'il fallait faire un grant pour que le client puisse se connecter à la BDD MySQL)

    PS : Mon hôte (serveur SQL) s'appelle localhost (mais finalement il faut mettre l'adresse ip du serveur SQL comme hôte), ma table que j'ai besoin : java

    Merci beaucoup pour votre aide. Un petit tuto sur MySQL en réseau local serai le bienvenue dans la rubrique MySQL (surtout pour les noobs comme moi)

  6. #6
    Expert éminent
    Avatar de Swoög
    Profil pro
    Inscrit en
    Janvier 2003
    Messages
    6 045
    Détails du profil
    Informations personnelles :
    Âge : 37
    Localisation : France

    Informations forums :
    Inscription : Janvier 2003
    Messages : 6 045
    Points : 8 339
    Points
    8 339
    Par défaut
    il ne faut jamais attribuer le nom localhost à un PC, il doit toujours y en avoir un autre, parce que localhost désigne toujours l'IP 127.0.0.1 soit le loopback (le PC qui éméet la requête)

  7. #7
    Membre à l'essai
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    26
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2006
    Messages : 26
    Points : 23
    Points
    23
    Par défaut
    OK, merci pour le conseil

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

Discussions similaires

  1. Requete HTTP sur serveur distant
    Par xenoise dans le forum Servlets/JSP
    Réponses: 1
    Dernier message: 05/11/2008, 12h24
  2. Réponses: 7
    Dernier message: 04/02/2008, 18h52
  3. Créer un dossier sur serveur distant
    Par TorÕ02 dans le forum C++
    Réponses: 7
    Dernier message: 11/10/2004, 17h30
  4. [Sybase] Accès Table sur serveur distant
    Par MashiMaro dans le forum Sybase
    Réponses: 5
    Dernier message: 11/02/2004, 14h09
  5. jsp sur serveur distant
    Par petitelulu dans le forum JBuilder
    Réponses: 5
    Dernier message: 11/09/2003, 11h50

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