From: Taber, Mark <Mark.Taber@dof.ca.gov>
To: Mohammad Tanvir Huda <shayer009@yahoo.com>
To: pgsql-admin@postgresql.org
Subject: Re: Connecting Postgres using other network
Date: Wed, 11 Aug 2004 13:03:29 -0700
Message-ID: <7660B79A29B9D411999F00D0B78EC8900B724ABC@NTRK2> (raw)
Dumb question, but are you sure you want port 6432 instead of 5432? Or was
this a typo?
Cheers,
Mark Taber
State of California
Department of Finance
Infrastructure & Architecture Unit
916.323.3104 x2945
_____
From: Mohammad Tanvir Huda [mailto:shayer009@yahoo.com]
Sent: Wednesday, August 11, 2004 12:40 PM
To: pgsql-admin@postgresql.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 <file:///\\load>
the driver
db =
DriverManager.getConnection("jdbc:postgresql://abc.csse.uts.edu:6432:test",
username,
password); file://connect
<file:///\\connect> to the db
dbmd = db.getMetaData(); file://get <file:///\\get> MetaData to
confirm connection
System.out.println("Connection to "+dbmd.getDatabaseProductName()+" "+
dbmd.getDatabaseProductVersion()+" successful.\n");
sql = db.createStatement(); file://create <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!
<http://us.rd.yahoo.com/mail_us/taglines/50x/*http:/promotions.yahoo.com/new
_mail/static/efficiency.html> Mail - 50x more storage than other providers!
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: Mark.Taber@dof.ca.gov, shayer009@yahoo.com
Subject: Re: Connecting Postgres using other network
In-Reply-To: <7660B79A29B9D411999F00D0B78EC8900B724ABC@NTRK2>
References: <7660B79A29B9D411999F00D0B78EC8900B724ABC@NTRK2>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox