pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Connecting Postgres using other network
10+ messages / 6 participants
[nested] [flat]

* Connecting Postgres using other network
@ 2004-08-11 19:39  Mohammad Tanvir Huda <shayer009@yahoo.com>
  0 siblings, 0 replies; 10+ messages in thread

From: Mohammad Tanvir Huda @ 2004-08-11 19:39 UTC (permalink / raw)
  To: pgsql-admin

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:test",
                                     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 - 50x more storage than other providers!

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Connecting Postgres using other network
@ 2004-08-11 19:59  Tom Haddon <thaddon@equilar.com>
  0 siblings, 0 replies; 10+ messages in thread

From: Tom Haddon @ 2004-08-11 19:59 UTC (permalink / raw)
  To: Mohammad Tanvir Huda <shayer009@yahoo.com>; pgsql-admin

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

	-----Original Message-----
	From: pgsql-admin-owner@postgresql.org
[mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Mohammad Tanvir
Huda
	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 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!

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Connecting Postgres using other network
@ 2004-08-11 20:03  Taber, Mark <Mark.Taber@dof.ca.gov>
  0 siblings, 0 replies; 10+ messages in thread

From: Taber, Mark @ 2004-08-11 20:03 UTC (permalink / raw)
  To: Mohammad Tanvir Huda <shayer009@yahoo.com>; pgsql-admin

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!

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Connecting Postgres using other network
@ 2004-08-11 20:32  Gustavo Franklin Nóbrega - PLANAE <gfnobrega@planae.com.br>
  0 siblings, 0 replies; 10+ messages in thread

From: Gustavo Franklin Nóbrega - PLANAE @ 2004-08-11 20:32 UTC (permalink / raw)
  To: pgsql-admin



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Connecting Postgres using other network
@ 2004-08-11 21:17  Bender, Cheryl <cbender@mriresearch.org>
  0 siblings, 1 reply; 10+ messages in thread

From: Bender, Cheryl @ 2004-08-11 21:17 UTC (permalink / raw)
  To: Mohammad Tanvir Huda <shayer009@yahoo.com>; pgsql-admin

A few things I would do;
 
1.  As other replies have mentioned check the port.  If you want to use
6432 I believe you have to put that in your conf file
2.  You need another line in your pg_hba.conf that provides access to
the network or specific IP and netmask of the computer you are
connecting from.  Lots of examples are found in the manual but I've put
one below
# Allow any user from any host with IP address 192.168.93.x to connect

# to database "template1" as the same user name that ident reports for

# the connection (typically the Unix user name).

# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD

host template1 all 192.168.93.0 255.255.255.0 ident sameuser

3.  Verify you can connect locally with the settings (especially if you
changed the port).
4.  If local connection works but your code still doesn't work, then
verify you can connect from the client if possible using something other
than jdbc (psql client tool or odbc).
5.  Check the log on the server.
 
Hope this helps some.
Cheryl
 
 

Cheryl Bender 
-----Original Message-----
From: pgsql-admin-owner@postgresql.org
[mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Mohammad Tanvir
Huda
Sent: Wednesday, August 11, 2004 2: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 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!

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Connecting Postgres using other network
@ 2004-08-12 01:45  Mohammad Tanvir Huda <shayer009@yahoo.com>
  parent: Bender, Cheryl <cbender@mriresearch.org>
  0 siblings, 1 reply; 10+ messages in thread

From: Mohammad Tanvir Huda @ 2004-08-12 01:45 UTC (permalink / raw)
  To: pgsql-admin

Hello All
Thanks for your reply. 
i want to use the port 6432 because some other instance of Postgresql is running on default port 5432,. And the psql command in this port works fine. 
 
/scratch/huda/bin/psql -p 6432 test 
 
If i want to allow any ip to get access to database what should i do. 
is the following this legal 
 
host template1 all 192.*.*.*  255.255.255.0 ident sameuser
 
Because when i hooked my PC to network it is assigned a dynamic IP . 
 
thirdly, as mentioned in previous email where can i find the psql client tool. 
 
Regards 
 
Tanvir 


"Bender, Cheryl" <cbender@mriresearch.org> wrote:
A few things I would do;
 
1.  As other replies have mentioned check the port.  If you want to use 6432 I believe you have to put that in your conf file
2.  You need another line in your pg_hba.conf that provides access to the network or specific IP and netmask of the computer you are connecting from.  Lots of examples are found in the manual but I've put one below

# Allow any user from any host with IP address 192.168.93.x to connect

# to database "template1" as the same user name that ident reports for

# the connection (typically the Unix user name).

# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD

host template1 all 192.168.93.0 255.255.255.0 ident sameuser

3.  Verify you can connect locally with the settings (especially if you changed the port).
4.  If local connection works but your code still doesn't work, then verify you can connect from the client if possible using something other than jdbc (psql client tool or odbc).
5.  Check the log on the server.
 
Hope this helps some.
Cheryl
 
 

Cheryl Bender 
-----Original Message-----
From: pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Mohammad Tanvir Huda
Sent: Wednesday, August 11, 2004 2: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 the driver
        db = DriverManager.getConnection("jdbc:postgresql://abc.csse.uts.edu:6432:test",
                                     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 - 50x more storage than other providers!

		
---------------------------------
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Connecting Postgres using other network
@ 2004-08-12 14:59  Mohammad Tanvir Huda <shayer009@yahoo.com>
  parent: Mohammad Tanvir Huda <shayer009@yahoo.com>
  0 siblings, 0 replies; 10+ messages in thread

From: Mohammad Tanvir Huda @ 2004-08-12 14:59 UTC (permalink / raw)
  To: pgsql-admin


Hello 
 
i have made some entry in pg_hba.conf so that it can accept call from other computers. 
 
But it still giving me the same error . 
 
Can anyone pls tell me what is wrong with that 
 
Regards 
Mohammad 
Mohammad Tanvir Huda <shayer009@yahoo.com> wrote:
Hello All
Thanks for your reply. 
i want to use the port 6432 because some other instance of Postgresql is running on default port 5432,. And the psql command in this port works fine. 
 
/scratch/huda/bin/psql -p 6432 test 
 
If i want to allow any ip to get access to database what should i do. 
is the following this legal 
 
host template1 all 192.*.*.*  255.255.255.0 ident sameuser
 
Because when i hooked my PC to network it is assigned a dynamic IP . 
 
thirdly, as mentioned in previous email where can i find the psql client tool. 
 
Regards 
 
Tanvir 


"Bender, Cheryl" <cbender@mriresearch.org> wrote:
A few things I would do;
 
1.  As other replies have mentioned check the port.  If you want to use 6432 I believe you have to put that in your conf file
2.  You need another line in your pg_hba.conf that provides access to the network or specific IP and netmask of the computer you are connecting from.  Lots of examples are found in the manual but I've put one below

# Allow any user from any host with IP address 192.168.93.x to connect

# to database "template1" as the same user name that ident reports for

# the connection (typically the Unix user name).

# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD

host template1 all 192.168.93.0 255.255.255.0 ident sameuser

3.  Verify you can connect locally with the settings (especially if you changed the port).
4.  If local connection works but your code still doesn't work, then verify you can connect from the client if possible using something other than jdbc (psql client tool or odbc).
5.  Check the log on the server.
 
Hope this helps some.
Cheryl
 
 

Cheryl Bender 
-----Original Message-----
From: pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Mohammad Tanvir Huda
Sent: Wednesday, August 11, 2004 2: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 the driver
        db = DriverManager.getConnection("jdbc:postgresql://abc.csse.uts.edu:6432:test",
                                     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 - 50x more storage than other providers!


---------------------------------
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.


		
---------------------------------
Do you Yahoo!?
Yahoo! Mail - You care about security. So do we.

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Connecting Postgres using other network
@ 2004-08-12 15:33  Andrew Janian <ajanian@scottrade.com>
  0 siblings, 1 reply; 10+ messages in thread

From: Andrew Janian @ 2004-08-12 15:33 UTC (permalink / raw)
  To: Mohammad Tanvir Huda <shayer009@yahoo.com>; pgsql-admin

Are you using -i option when you start Postgres?  If not, it will not allow remote requests even if you have the ACL set correctly.
 
Andrew

-----Original Message-----
From: pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql.org]On Behalf Of Mohammad Tanvir Huda
Sent: Thursday, August 12, 2004 10:00 AM
To: pgsql-admin@postgresql.org
Subject: Re: [ADMIN] Connecting Postgres using other network 



Hello 
 
i have made some entry in pg_hba.conf so that it can accept call from other computers. 
 
But it still giving me the same error . 
 
Can anyone pls tell me what is wrong with that 
 
Regards 
Mohammad 
Mohammad Tanvir Huda <shayer009@yahoo.com> wrote:

Hello All
Thanks for your reply. 
i want to use the port 6432 because some other instance of Postgresql is running on default port 5432,. And the psql command in this port works fine. 
 
/scratch/huda/bin/psql -p 6432 test 
 
If i want to allow any ip to get access to database what should i do. 
is the following this legal 
 
host template1 all 192.*.*.*  255.255.255.0 ident sameuser
 
Because when i hooked my PC to network it is assigned a dynamic IP . 
 
thirdly, as mentioned in previous email where can i find the psql client tool. 
 
Regards 
 
Tanvir 


"Bender, Cheryl" <cbender@mriresearch.org> wrote:

A few things I would do;
 
1.  As other replies have mentioned check the port.  If you want to use 6432 I believe you have to put that in your conf file
2.  You need another line in your pg_hba.conf that provides access to the network or specific IP and netmask of the computer you are connecting from.  Lots of examples are found in the manual but I've put one below
# Allow any user from any host with IP address 192.168.93.x to connect

# to database "template1" as the same user name that ident reports for

# the connection (typically the Unix user name).

# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD

host template1 all 192.168.93.0 255.255.255.0 ident sameuser

3.  Verify you can connect locally with the settings (especially if you changed the port).
4.  If local connection works but your code still doesn't work, then verify you can connect from the client if possible using something other than jdbc (psql client tool or odbc).
5.  Check the log on the server.
 
Hope this helps some.
Cheryl
 
 

Cheryl Bender 
-----Original Message-----
From: pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Mohammad Tanvir Huda
Sent: Wednesday, August 11, 2004 2: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....; Mail - 50x more storage than other providers!



  _____  

Do you Yahoo!?
Yahoo!  <http://us.rd.yahoo.com/mail_us/taglines/aac/*http://promotions.yahoo.com/new_mail/static/ease.html; Mail Address AutoComplete - You start. We finish.



  _____  

Do you Yahoo!?
Yahoo!  <http://us.rd.yahoo.com/mail_us/taglines/security/*http://promotions.yahoo.com/new_mail/static/protec...; Mail - You care about security. So do we.

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Connecting Postgres using other network
@ 2004-08-13 01:29  Mohammad Tanvir Huda <shayer009@yahoo.com>
  parent: Andrew Janian <ajanian@scottrade.com>
  0 siblings, 0 replies; 10+ messages in thread

From: Mohammad Tanvir Huda @ 2004-08-13 01:29 UTC (permalink / raw)
  To: Andrew Janian <ajanian@scottrade.com>; +Cc: pgsql-admin

I set the tcp_ip=true in postgresql.conf file. Isn't that the same thing while starting up postmaster with -i. Becasue i am starting up the server using pg_ctl . 
 
Regards 
 


Andrew Janian <ajanian@scottrade.com> wrote:
Are you using -i option when you start Postgres?  If not, it will not allow remote requests even if you have the ACL set correctly.
 
Andrew
-----Original Message-----
From: pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql.org]On Behalf Of Mohammad Tanvir Huda
Sent: Thursday, August 12, 2004 10:00 AM
To: pgsql-admin@postgresql.org
Subject: Re: [ADMIN] Connecting Postgres using other network 



Hello 
 
i have made some entry in pg_hba.conf so that it can accept call from other computers. 
 
But it still giving me the same error . 
 
Can anyone pls tell me what is wrong with that 
 
Regards 
Mohammad 
Mohammad Tanvir Huda <shayer009@yahoo.com> wrote:
Hello All
Thanks for your reply. 
i want to use the port 6432 because some other instance of Postgresql is running on default port 5432,. And the psql command in this port works fine. 
 
/scratch/huda/bin/psql -p 6432 test 
 
If i want to allow any ip to get access to database what should i do. 
is the following this legal 
 
host template1 all 192.*.*.*  255.255.255.0 ident sameuser
 
Because when i hooked my PC to network it is assigned a dynamic IP . 
 
thirdly, as mentioned in previous email where can i find the psql client tool. 
 
Regards 
 
Tanvir 


"Bender, Cheryl" <cbender@mriresearch.org> wrote:
A few things I would do;
 
1.  As other replies have mentioned check the port.  If you want to use 6432 I believe you have to put that in your conf file
2.  You need another line in your pg_hba.conf that provides access to the network or specific IP and netmask of the computer you are connecting from.  Lots of examples are found in the manual but I've put one below

# Allow any user from any host with IP address 192.168.93.x to connect

# to database "template1" as the same user name that ident reports for

# the connection (typically the Unix user name).

# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD

host template1 all 192.168.93.0 255.255.255.0 ident sameuser

3.  Verify you can connect locally with the settings (especially if you changed the port).
4.  If local connection works but your code still doesn't work, then verify you can connect from the client if possible using something other than jdbc (psql client tool or odbc).
5.  Check the log on the server.
 
Hope this helps some.
Cheryl
 
 

Cheryl Bender 
-----Original Message-----
From: pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Mohammad Tanvir Huda
Sent: Wednesday, August 11, 2004 2: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 the driver
        db = DriverManager.getConnection("jdbc:postgresql://abc.csse.uts.edu:6432:test",
                                     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 - 50x more storage than other providers!


---------------------------------
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.



---------------------------------
Do you Yahoo!?
Yahoo! Mail - You care about security. So do we.
		
---------------------------------
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Connecting Postgres using other network
@ 2004-08-13 12:25  Andrew Janian <ajanian@scottrade.com>
  0 siblings, 0 replies; 10+ messages in thread

From: Andrew Janian @ 2004-08-13 12:25 UTC (permalink / raw)
  To: Mohammad Tanvir Huda <shayer009@yahoo.com>; +Cc: pgsql-admin

Should be the same.
 
Andrew

-----Original Message-----
From: Mohammad Tanvir Huda [mailto:shayer009@yahoo.com]
Sent: Thursday, August 12, 2004 8:29 PM
To: Andrew Janian
Cc: pgsql-admin@postgresql.org
Subject: Re: [ADMIN] Connecting Postgres using other network 


I set the tcp_ip=true in postgresql.conf file. Isn't that the same thing while starting up postmaster with -i. Becasue i am starting up the server using pg_ctl . 
 
Regards 
 


Andrew Janian <ajanian@scottrade.com> wrote:

Are you using -i option when you start Postgres?  If not, it will not allow remote requests even if you have the ACL set correctly.
 
Andrew

-----Original Message-----
From: pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql.org]On Behalf Of Mohammad Tanvir Huda
Sent: Thursday, August 12, 2004 10:00 AM
To: pgsql-admin@postgresql.org
Subject: Re: [ADMIN] Connecting Postgres using other network 



Hello 
 
i have made some entry in pg_hba.conf so that it can accept call from other computers. 
 
But it still giving me the same error . 
 
Can anyone pls tell me what is wrong with that 
 
Regards 
Mohammad 
Mohammad Tanvir Huda <shayer009@yahoo.com> wrote:

Hello All
Thanks for your reply. 
i want to use the port 6432 because some other instance of Postgresql is running on default port 5432,. And the psql command in this port works fine. 
 
/scratch/huda/bin/psql -p 6432 test 
 
If i want to allow any ip to get access to database what should i do. 
is the following this legal 
 
host template1 all 192.*.*.*  255.255.255.0 ident sameuser
 
Because when i hooked my PC to network it is assigned a dynamic IP . 
 
thirdly, as mentioned in previous email where can i find the psql client tool. 
 
Regards 
 
Tanvir 


"Bender, Cheryl" <cbender@mriresearch.org> wrote:

A few things I would do;
 
1.  As other replies have mentioned check the port.  If you want to use 6432 I believe you have to put that in your conf file
2.  You need another line in your pg_hba.conf that provides access to the network or specific IP and netmask of the computer you are connecting from.  Lots of examples are found in the manual but I've put one below
# Allow any user from any host with IP address 192.168.93.x to connect

# to database "template1" as the same user name that ident reports for

# the connection (typically the Unix user name).

# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD

host template1 all 192.168.93.0 255.255.255.0 ident sameuser

3.  Verify you can connect locally with the settings (especially if you changed the port).
4.  If local connection works but your code still doesn't work, then verify you can connect from the client if possible using something other than jdbc (psql client tool or odbc).
5.  Check the log on the server.
 
Hope this helps some.
Cheryl
 
 

Cheryl Bender 
-----Original Message-----
From: pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Mohammad Tanvir Huda
Sent: Wednesday, August 11, 2004 2: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....; Mail - 50x more storage than other providers!



  _____  

Do you Yahoo!?
Yahoo!  <http://us.rd.yahoo.com/mail_us/taglines/aac/*http://promotions.yahoo.com/new_mail/static/ease.html; Mail Address AutoComplete - You start. We finish.



  _____  

Do you Yahoo!?
Yahoo!  <http://us.rd.yahoo.com/mail_us/taglines/security/*http://promotions.yahoo.com/new_mail/static/protec...; Mail - You care about security. So do we.



  _____  

Do you Yahoo!?
New  <http://us.rd.yahoo.com/mail_us/taglines/100/*http://promotions.yahoo.com/new_mail/static/efficiency....; and Improved Yahoo! Mail - 100MB free storage!

^ permalink  raw  reply  [nested|flat] 10+ messages in thread


end of thread, other threads:[~2004-08-13 12:25 UTC | newest]

Thread overview: 10+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-08-11 19:39 Connecting Postgres using other network Mohammad Tanvir Huda <shayer009@yahoo.com>
2004-08-11 19:59 Re: Connecting Postgres using other network Tom Haddon <thaddon@equilar.com>
2004-08-11 20:03 Re: Connecting Postgres using other network Taber, Mark <Mark.Taber@dof.ca.gov>
2004-08-11 20:32 Re: Connecting Postgres using other network Gustavo Franklin Nóbrega - PLANAE <gfnobrega@planae.com.br>
2004-08-11 21:17 Re: Connecting Postgres using other network Bender, Cheryl <cbender@mriresearch.org>
2004-08-12 01:45 ` Mohammad Tanvir Huda <shayer009@yahoo.com>
2004-08-12 14:59   ` Mohammad Tanvir Huda <shayer009@yahoo.com>
2004-08-12 15:33 Re: Connecting Postgres using other network Andrew Janian <ajanian@scottrade.com>
2004-08-13 01:29 ` Mohammad Tanvir Huda <shayer009@yahoo.com>
2004-08-13 12:25 Re: Connecting Postgres using other network Andrew Janian <ajanian@scottrade.com>

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