Re: Connecting Postgres using other network

From: "Tom Haddon" <thaddon(at)equilar(dot)com>
To: "Mohammad Tanvir Huda" <shayer009(at)yahoo(dot)com>, <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Connecting Postgres using other network
Date: 2004-08-11 19:59:45
Message-ID: 0E52D69E86D25840AAE3611CB657F9F80AA023@millenium.equilar.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Just to check, you are using a non-standard port (6432 - the standard is
5432)?

-----Original Message-----
From: pgsql-admin-owner(at)postgresql(dot)org
[mailto:pgsql-admin-owner(at)postgresql(dot)org] On Behalf Of Mohammad Tanvir
Huda
Sent: Wednesday, August 11, 2004 12:40 PM
To: pgsql-admin(at)postgresql(dot)org
Subject: [ADMIN] Connecting Postgres using other network


Hello Everyone

I have installed Postgres server in a network and i am trying
to use the database using
Java code from other network.

I have set the tcp_ip=true in postgresql.conf file.
I have also add the follwing line in the pg_hba.conf

host all all 127.0.0.0
255.255.255.255 trust

Then i start the server in port 6432.

After that i want to access the application using the following
javacode.

import java.sql.*; // All we need for JDBC
import java.text.*;
import java.io.*;
public class HelloPost
{
Connection db; // A connection to the database
Statement sql; // Our statement to run queries
with
DatabaseMetaData dbmd; // This is basically info the
driver delivers
// about the DB it just connected
to. I use
// it to get the DB version to
confirm the
// connection in this example.
public HelloPost()
throws ClassNotFoundException, SQLException
{
String database = "test";
String username = "abc";
String password = "xyz";
try{
Class.forName("org.postgresql.Driver"); file://load the
driver
db =
DriverManager.getConnection("jdbc:postgresql://abc.csse.uts.edu:6432:tes
t",
username,
password); file://connect
to the db
dbmd = db.getMetaData(); file://get MetaData to confirm
connection
System.out.println("Connection to
"+dbmd.getDatabaseProductName()+" "+
dbmd.getDatabaseProductVersion()+"
successful.\n");
sql = db.createStatement(); file://create a statement that
we can use later
}catch (ClassNotFoundException e) {
System.err.println( "Driver not found: " + e + "\n"
+ e.getMessage() );
}
db.close();
}
public static void main (String args[])
{
try
{
HelloPost demo = new HelloPost();
}
catch (Exception ex)
{
System.out.println("***Exception:\n"+ex);
ex.printStackTrace();
}
}
}

But this give me the following error

Exception: org.postgresql.util.PSQLException: Connection
refused. Check that the hostname and port are correct and that the post
accepting TCP/IP connections.
Connection refused. Check that the hostname and port are correct
and that the postmaster is accepting TCP/IP connections.

Can anyone please tell me where is the error. what should i doo
..

regards

Shayer


________________________________

Do you Yahoo!?
Yahoo! Mail
<http://us.rd.yahoo.com/mail_us/taglines/50x/*http://promotions.yahoo.co
m/new_mail/static/efficiency.html> - 50x more storage than other
providers!

Browse pgsql-admin by date

  From Date Subject
Next Message Taber, Mark 2004-08-11 20:03:29 Re: Connecting Postgres using other network
Previous Message Mohammad Tanvir Huda 2004-08-11 19:39:47 Connecting Postgres using other network