X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EBB1114B281C for ; Wed, 11 Aug 2004 16:58:18 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 27625-06 for ; Wed, 11 Aug 2004 19:58:09 +0000 (GMT) Received: from millenium.equilar.com (eth0.1720amphlett.sm.libritas.com [209.0.100.158]) by svr1.postgresql.org (Postfix) with ESMTP id 1A0B714B27FF for ; Wed, 11 Aug 2004 16:58:08 -0300 (ADT) Content-class: urn:content-classes:message MIME-Version: 1.0 Subject: Re: Connecting Postgres using other network Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C47FDD.BFCA59CF" X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Date: Wed, 11 Aug 2004 12:59:45 -0700 Message-ID: <0E52D69E86D25840AAE3611CB657F9F80AA023@millenium.equilar.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [ADMIN] Connecting Postgres using other network Thread-Index: AcR/3ZY7TkiByt46TpyAqqxNglfaVgAAB+EA From: "Tom Haddon" To: "Mohammad Tanvir Huda" , X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.1 tagged_above=0.0 required=5.0 tests=HTML_30_40, HTML_FONTCOLOR_BLUE, HTML_FONTCOLOR_RED, HTML_FONTCOLOR_UNSAFE, HTML_MESSAGE X-Spam-Level: * X-Archive-Number: 200408/76 X-Sequence-Number: 14471 This is a multi-part message in MIME format. ------_=_NextPart_001_01C47FDD.BFCA59CF Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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=20 =09 =09 Hello Everyone=20 =09=20 I have installed Postgres server in a network and i am trying to use the database using=20 Java code from other network.=20 =09=20 I have set the tcp_ip=3Dtrue in postgresql.conf file.=20 I have also add the follwing line in the pg_hba.conf =09 host all all 127.0.0.0 255.255.255.255 trust =09=20 Then i start the server in port 6432.=20 =09=20 After that i want to access the application using the following javacode.=20 =09=20 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 =3D "test"; String username =3D "abc"; String password =3D "xyz"; try{ Class.forName("org.postgresql.Driver"); file://load the driver db =3D DriverManager.getConnection("jdbc:postgresql://abc.csse.uts.edu:6432:tes t", username, password); file://connect to the db dbmd =3D db.getMetaData(); file://get MetaData to confirm connection System.out.println("Connection to "+dbmd.getDatabaseProductName()+" "+ dbmd.getDatabaseProductVersion()+" successful.\n"); sql =3D 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 =3D new HelloPost(); } catch (Exception ex) { System.out.println("***Exception:\n"+ex); ex.printStackTrace(); } } } =09 But this give me the following error=20 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. =09 Can anyone please tell me where is the error. what should i doo ..=20 =09=20 regards=20 =09=20 Shayer=20 =09=20 =09 ________________________________ Do you Yahoo!? Yahoo! Mail - 50x more storage than other providers! ------_=_NextPart_001_01C47FDD.BFCA59CF Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Message
Just=20 to check, you are using a non-standard port (6432 - the standard is=20 5432)?
-----Original Message-----
From:=20 pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql.org= ]=20 On Behalf Of Mohammad Tanvir Huda
Sent: Wednesday, Augus= t 11,=20 2004 12:40 PM
To: pgsql-admin@postgresql.org
Subject:= =20 [ADMIN] Connecting Postgres using other network

Hello Everyone
 
I have installed Postgres server in a network and  i am trying = to=20 use the database using
Java code from other network.
 
I have set the tcp_ip=3Dtrue in postgresql.conf file.
I have also add the follwing line in the=20 pg_hba.conf

host   =20 all        =20 all       =20 127.0.0.0         =20 255.255.255.255   trust
 
Then i start the server in port 6432.
 
After that i want to access the application using the following java= code.=20
 
import java.sql.*;   // All we need for JDBC
import=20 java.text.*;
import java.io.*;
public class HelloPost
{
 =20 Connection      =20 db;        // A connection to the=20 database
  Statement       =20 sql;       // Our statement to run queries= =20 with
  DatabaseMetaData dbmd;      // Th= is is=20 basically info the driver=20 delivers
          &= nbsp;           &nbs= p;      =20 // about the DB it just connected to. I=20 use
           =             &nb= sp;     =20 // it to get the DB version to confirm=20 the
           =             &nb= sp;     =20 // connection in this example.
  public HelloPost()
    throws=20 ClassNotFoundException, SQLException
  {
    St= ring=20 database =3D "test";
    String username =3D=20 "abc";
    String password =3D "xyz";
    try{
   =20  Class.forName("org.postgresql.Driver"); file://load the=20 driver
        db =3D=20 DriverManager.getConnection("jdbc:postgresql://abc.csse.uts.edu:6432:test= ",
           &nb= sp;            =             =20 username,
          =             &nb= sp;            =  =20 password); file://connect to the=20 db
     dbmd =3D db.getMetaData(); file://get MetaData to confirm=20 connection
     System.out.println("Connection to= =20 "+dbmd.getDatabaseProductName()+"=20 "+
           &= nbsp;          =20 dbmd.getDatabaseProductVersion()+" successful.\n");
   = =20  sql =3D db.createStatement(); file://crea= te a=20 statement that we can use later
    }catch=20 (ClassNotFoundException e)=20 {
           = =20 System.err.println( "Driver not found: " + e + "\n" + e.getMessage()=20 );
    }
    db.close();
  }
 public static void main (String args[])
   {
     try
    =20 {
       HelloPost demo =3D new=20 HelloPost();
     }
     ca= tch=20 (Exception ex)
    =20 {
      =20 System.out.println("***Exception:\n"+ex);
    &nbs= p; =20 ex.printStackTrace();
     }
  =20 }
 }
But this give me the following error= =20

Exception:=20 org.postgresql.util.PSQLException: Connection refused. Check that the hos= tname=20 and port are correct and that the post
 accepting TCP/IP=20 connections.
Connection refused. Check that the hostname and port are= =20 correct and that the postmaster is accepting TCP/IP=20 connections
.
Can anyone please tell me where is the error. what should i doo .. <= /DIV>
 
regards
 
Shayer
 


Do you Yahoo!?
Yahoo!=20 Mail - 50x more storage than other providers!
=00 ------_=_NextPart_001_01C47FDD.BFCA59CF--