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 8689814B2806 for ; Wed, 11 Aug 2004 17:05:22 -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 42300-08 for ; Wed, 11 Aug 2004 20:05:13 +0000 (GMT) Received: from ntrk2.DOF (exchange.dof.ca.gov [134.186.75.161]) by svr1.postgresql.org (Postfix) with ESMTP id 7A79D14B281A for ; Wed, 11 Aug 2004 17:05:11 -0300 (ADT) Received: by NTRK2 with Internet Mail Service (5.5.2657.72) id ; Wed, 11 Aug 2004 13:03:29 -0700 Message-ID: <7660B79A29B9D411999F00D0B78EC8900B724ABC@NTRK2> From: "Taber, Mark" To: Mohammad Tanvir Huda , pgsql-admin@postgresql.org Subject: Re: Connecting Postgres using other network Date: Wed, 11 Aug 2004 13:03:29 -0700 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2657.72) Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C47FDE.44F41772" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.5 tagged_above=0.0 required=5.0 tests=HTML_60_70, HTML_FONTCOLOR_RED, HTML_FONTCOLOR_UNKNOWN, HTML_FONTCOLOR_UNSAFE, HTML_MESSAGE, MAILTO_TO_SPAM_ADDR X-Spam-Level: * X-Archive-Number: 200408/77 X-Sequence-Number: 14472 This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C47FDE.44F41772 Content-Type: text/plain 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 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! ------_=_NextPart_001_01C47FDE.44F41772 Content-Type: text/html Content-Transfer-Encoding: quoted-printable

Dumb question, but are you sure you wa= nt 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<= o:p>


From: Mohammad= Tanvir Huda [mailto:shayer009@yahoo.com]
Sent: Wednesday, August 11, = 2004 12:40 PM
To: pgsql-admin@postgresql.o= rg
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=3Dtrue 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 databa= se
  Statement        sql;       // Our statement to run queries wi= th
  DatabaseMetaData dbmd;      // This is basically info the driver delivers
            &nb= sp;            =      // about the DB it just connected to. I use
            &nb= sp;            =      // it to get the DB version to confirm the
            &nb= sp;            =      // 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.getConnecti= on("jdbc:postgresql://abc.csse.uts.edu:6432:test",
            &nb= sp;            =             username,
            &nb= sp;            =             password); file://connect to the db
     dbmd =3D db.getMetaData(); file://get MetaData to confirm connection
     System.out.println("Connection to "+dbmd.getDatabaseProductName()+" "+
            &nb= sp;          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();
     }
   }
 }

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 connection= s.
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!
<= /p>

------_=_NextPart_001_01C47FDE.44F41772--