Java-postgres

Résolu
cazersose - 20 mai 2008 à 14:21
vlmath Messages postés 794 Date d'inscription vendredi 20 octobre 2006 Statut Contributeur Dernière intervention 4 septembre 2011 -
Bonjour,
voila g un souci avec ce bout de code et je vois ou est mon erreur svp c urgent merci
public class postgresql {

postgresql(String dbname ,String user ,String password)
{
try {
Class.forName("org.postgresql.Driver");

}
catch (Exception E) {
System.err.println("Pas de pilote !");
}
try
{ String url = "jdbc:postgresql://IP:PORT/dbname";

Connection conn=DriverManager.getConnection(url, "user", "password");
System.out.println("Connection établie !");
}
catch(Exception E)
{
System.err.println("Connection n'établie pas etablie !");
}

}
}
j'ai toujour exception connection pas etablie
j'ai chercher le fichier config postgres.conf pour configurer la possiblité d'un connection tcp/ip mais g pa trouver
la ligne c bizzar
tcpip_socket = true alors help me please ??? merci les pote d'avance
A voir également:

4 réponses

vlmath Messages postés 794 Date d'inscription vendredi 20 octobre 2006 Statut Contributeur Dernière intervention 4 septembre 2011 160
20 mai 2008 à 18:37
Salut,

Là, tu as pris la signature du connecteur pour un SGBD MySql, et non PostGresSQL, qui est légèrement différent :
Connection conn=DriverManager.getConnection("jdbc:postgresql://IP:PORT/dbname?user=' '&password=' ' ");
(Simple quot pour le user et le password).

@Bientôt

PS : t'as du bol, j'ai fais ça il y a deux heures ... :D
1
vlmath Messages postés 794 Date d'inscription vendredi 20 octobre 2006 Statut Contributeur Dernière intervention 4 septembre 2011 160
20 mai 2008 à 18:36
Salut,

Là, tu as pris la signature du connecteur pour un SGBD MySql, et non PostGresSQL, qui est légèrement différent :
Connection conn=DriverManager.getConnection("jdbc:postgresql://IP:PORT/dbname?user=' '&password=' ' ");
(Simple quot pour le user et le password).

@Bientôt
0
merci boss
0
vlmath Messages postés 794 Date d'inscription vendredi 20 octobre 2006 Statut Contributeur Dernière intervention 4 septembre 2011 160
20 mai 2008 à 19:34
Mais c'est tout normal ... :D
0

Discussions similaires