Thread: Connecting Postgres using other network
host all all 127.0.0.0 255.255.255.255 trust
import java.text.*;
import java.io.*;
{
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.
throws ClassNotFoundException, SQLException
{
String database = "test";
String username = "abc";
String password = "xyz";
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() );
}
}
{
{
HelloPost demo = new HelloPost();
}
catch (Exception ex)
{
System.out.println("***Exception:\n"+ex);
ex.printStackTrace();
}
}
}
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.
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
-----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 networkHello EveryoneI have installed Postgres server in a network and i am trying to use the database usingJava 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 trustThen 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 ..regardsShayer
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
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!
# 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
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 EveryoneI have installed Postgres server in a network and i am trying to use the database usingJava 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 trustThen 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 ..regardsShayer
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
"Bender, Cheryl" <cbender@mriresearch.org> wrote:
# 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
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 EveryoneI have installed Postgres server in a network and i am trying to use the database usingJava 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 trustThen 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 ..regardsShayer
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
Hello
Mohammad Tanvir Huda <shayer009@yahoo.com> wrote:
Hello AllThanks 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 testIf i want to allow any ip to get access to database what should i do.is the following this legalhost template1 all 192.*.*.* 255.255.255.0 ident sameuserBecause 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.RegardsTanvir
"Bender, Cheryl" <cbender@mriresearch.org> wrote:
# 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
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 EveryoneI have installed Postgres server in a network and i am trying to use the database usingJava 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 trustThen 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 ..regardsShayer
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.
-----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
Helloi 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 thatRegardsMohammad
Mohammad Tanvir Huda <shayer009@yahoo.com> wrote:Hello AllThanks 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 testIf i want to allow any ip to get access to database what should i do.is the following this legalhost template1 all 192.*.*.* 255.255.255.0 ident sameuserBecause 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.RegardsTanvir
"Bender, Cheryl" <cbender@mriresearch.org> wrote:
# 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
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 EveryoneI have installed Postgres server in a network and i am trying to use the database usingJava 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 trustThen 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 ..regardsShayer
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.
Andrew Janian <ajanian@scottrade.com> wrote:
-----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
Helloi 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 thatRegardsMohammad
Mohammad Tanvir Huda <shayer009@yahoo.com> wrote:Hello AllThanks 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 testIf i want to allow any ip to get access to database what should i do.is the following this legalhost template1 all 192.*.*.* 255.255.255.0 ident sameuserBecause 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.RegardsTanvir
"Bender, Cheryl" <cbender@mriresearch.org> wrote:
# 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
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 EveryoneI have installed Postgres server in a network and i am trying to use the database usingJava 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 trustThen 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 ..regardsShayer
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!
-----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 networkI 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:
-----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
Helloi 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 thatRegardsMohammad
Mohammad Tanvir Huda <shayer009@yahoo.com> wrote:Hello AllThanks 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 testIf i want to allow any ip to get access to database what should i do.is the following this legalhost template1 all 192.*.*.* 255.255.255.0 ident sameuserBecause 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.RegardsTanvir
"Bender, Cheryl" <cbender@mriresearch.org> wrote:
# 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
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 EveryoneI have installed Postgres server in a network and i am trying to use the database usingJava 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 trustThen 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 ..regardsShayer
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!