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 :

Erreur de connexion à la bd Postgres


Sujet :

JDBC Java

  1. #1
    Membre du Club
    Femme Profil pro
    Inscrit en
    Mai 2011
    Messages
    177
    Détails du profil
    Informations personnelles :
    Sexe : Femme

    Informations forums :
    Inscription : Mai 2011
    Messages : 177
    Points : 50
    Points
    50
    Par défaut Erreur de connexion à la bd Postgres
    Bonjour,
    je travaille avec postgres sql 9.2. j'ai téléchargé son jdbc et je l'ai affecté au build path du projet.
    J'ai créé une classe pour tester si la connexion est bien établie.

    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 com.database.util;
     
    import java.sql.Connection;
    import java.sql.DriverManager;
     
     
    public class Connect {
    	  public static void main(String[] args) {     
    	    try {
    	      Class.forName("org.postgresql.Driver");
    	      System.out.println("Driver O.K.");
     
    	      String url = "jdbc:postgresql://localhost:5432/postgres";
    	      String user = "admin";
    	      String passwd = "admin";
     
    	      Connection conn = DriverManager.getConnection(url, user, passwd);
    	      System.out.println("Connexion effective !");        
     
    	    } catch (Exception e) {
    	      e.printStackTrace();
    	    }     
    	  }
    	}
    voici le résultat
    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
     
    Driver O.K.
    org.postgresql.util.PSQLException: FATAL: authentification par mot de passe ?chou?e pour l'utilisateur  ? admin ?
    	at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:398)
    	at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:173)
    	at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:64)
    	at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:136)
    	at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:29)
    	at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(AbstractJdbc3gConnection.java:21)
    	at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:31)
    	at org.postgresql.jdbc4.Jdbc4Connection.<init>(Jdbc4Connection.java:24)
    	at org.postgresql.Driver.makeConnection(Driver.java:393)
    	at org.postgresql.Driver.connect(Driver.java:267)
    	at java.sql.DriverManager.getConnection(Unknown Source)
    	at java.sql.DriverManager.getConnection(Unknown Source)
    	at com.database.util.Connect.main(Connect.java:17)

    sachant que je suis sur de numero de port(5432) ainsi que le login:admin et le mot de passe: admin. (j'ai meme réinstallé postgres afin d'etre des login+mdp)

  2. #2
    Membre du Club Avatar de Mednet
    Homme Profil pro
    Consultant informatique
    Inscrit en
    Juillet 2011
    Messages
    53
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Consultant informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2011
    Messages : 53
    Points : 50
    Points
    50
    Par défaut
    Salut,

    par défaut :

    User = 'postgres'
    password = 'admin'

  3. #3
    Membre du Club Avatar de Mednet
    Homme Profil pro
    Consultant informatique
    Inscrit en
    Juillet 2011
    Messages
    53
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Consultant informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2011
    Messages : 53
    Points : 50
    Points
    50
    Par défaut
    so you must change the username on your programme,

    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
     
    import java.sql.Connection;
    import java.sql.DriverManager;
     
     
    public class Connect {
    	  public static void main(String[] args) {     
    	    try {
    	      Class.forName("org.postgresql.Driver");
    	      System.out.println("Driver O.K.");
     
    	      String url = "jdbc:postgresql://localhost:5432/postgres";
    	      String user = "postgres";
    	      String passwd = "admin";
     
    	      Connection conn = DriverManager.getConnection(url, user, passwd);
    	      System.out.println("Connexion effective !");        
     
    	    } catch (Exception e) {
    	      e.printStackTrace();
    	    }     
    	  }
    	}

  4. #4
    Membre du Club
    Femme Profil pro
    Inscrit en
    Mai 2011
    Messages
    177
    Détails du profil
    Informations personnelles :
    Sexe : Femme

    Informations forums :
    Inscription : Mai 2011
    Messages : 177
    Points : 50
    Points
    50
    Par défaut
    merci ça marche

Discussions similaires

  1. [Postgres][PHP]Erreur de connexion
    Par duckaurore dans le forum PostgreSQL
    Réponses: 3
    Dernier message: 11/01/2007, 10h41
  2. Erreur de connexion au serveur SQL 3
    Par NeHuS dans le forum Langage SQL
    Réponses: 3
    Dernier message: 28/01/2005, 13h55
  3. Erreur de connexion à ma base sur serveur Debian - Apache
    Par GLDavid dans le forum Installation
    Réponses: 4
    Dernier message: 24/09/2003, 10h29
  4. Pgsql : erreur de connexion 'too many clients ...'
    Par petitmoosse dans le forum PostgreSQL
    Réponses: 3
    Dernier message: 21/08/2003, 14h03
  5. Erreur de connexion à PostGresql via pgAdminII
    Par LS dans le forum PostgreSQL
    Réponses: 4
    Dernier message: 21/08/2003, 09h51

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