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 0AA4814B2827 for ; Wed, 11 Aug 2004 16:40:31 -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 03377-01 for ; Wed, 11 Aug 2004 19:40:21 +0000 (GMT) Received: from web60307.mail.yahoo.com (web60307.mail.yahoo.com [216.109.118.118]) by svr1.postgresql.org (Postfix) with SMTP id ABB4314B27FF for ; Wed, 11 Aug 2004 16:39:48 -0300 (ADT) Message-ID: <20040811193947.26048.qmail@web60307.mail.yahoo.com> Received: from [210.49.209.238] by web60307.mail.yahoo.com via HTTP; Wed, 11 Aug 2004 12:39:47 PDT Date: Wed, 11 Aug 2004 12:39:47 -0700 (PDT) From: Mohammad Tanvir Huda Subject: Connecting Postgres using other network To: pgsql-admin@postgresql.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-353719706-1092253187=:23443" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=2.0 tagged_above=0.0 required=5.0 tests=FROM_ENDS_IN_NUMS, HTML_30_40, HTML_FONTCOLOR_RED, HTML_FONTCOLOR_UNSAFE, HTML_MESSAGE, RCVD_IN_SORBS X-Spam-Level: * X-Archive-Number: 200408/75 X-Sequence-Number: 14470 --0-353719706-1092253187=:23443 Content-Type: text/plain; charset=us-ascii 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! --0-353719706-1092253187=:23443 Content-Type: text/html; charset=us-ascii
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! --0-353719706-1092253187=:23443--