• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

postgres connectivity failure with jdbc

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You did remember to start the PostgreSQL server, didn't you?

/sbin/service postgresql start
 
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
scott, please mention the whole command ...i cant understand by that -i option only
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic