• Post Reply Bookmark Topic Watch Topic
  • New Topic

postgres connectivity failure with jdbc  RSS feed

 
mudassir shahab
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am using redhat 9 with postgres 7.3...when i run the program below it gives the following error :

SQL EXCEPTION Connection refused. Check that the hostname and port are correct
and that the postmaster is accepting TCP/IP connections.
------------------

program :


import java.sql.*;

class mydb

{

public static void main(String [] args)

{
Connection dbconn ;
Statement stmt ;
ResultSet author ;
String sourceURL = "jdbc ostgresql://localhost/synergy";
try
{

Class.forName("org.postgresql.Driver");

dbconn = DriverManager.getConnection(sourceURL,"monte","powers");
stmt = dbconn.createStatement();
author = stmt.executeQuery("SELECT * FROM cust_info");


while(author.next())
{

System.out.println(author.getString("cust_id"));
}


dbconn.setAutoCommit(true);

stmt.close() ;

}


catch(ClassNotFoundException cnfe){

System.out.println("CLASS NOT FOUND EXCEPTION "+cnfe);

}

catch(SQLException sqle){

System.out.println("SQL EXCEPTION "+sqle);

}
}
}

---------------------------------------------

i have also made changes in pg_hba.conf

host all all 127.0.0.1 255.255.255.255 trust

and postgres.conf (whatever the exact name) where i made

tcpip_socket = true


-------------plz have a look
 
Tim Holloway
Saloon Keeper
Posts: 18799
74
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You did remember to start the PostgreSQL server, didn't you?

/sbin/service postgresql start
 
Scott Dunbar
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As a test, start the PostgreSQL postmaster with the "-i" flag. This should be the same as the tcpip_socket config parameter but it may help to debug what is going on.
 
mudassir shahab
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
scott, please mention the whole command ...i cant understand by that -i option only
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!