aspose file tools*
The moose likes JDBC and the fly likes Postgresql connection Failure Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Postgresql connection Failure" Watch "Postgresql connection Failure" New topic
Author

Postgresql connection Failure

jonas okwara
Ranch Hand

Joined: Jun 22, 2004
Posts: 58
please can anyone help me. I have the following error messages and i have been troubleshooting it since yesterday without success.


" org.postgresl.util.PSQLEXCEPTION:The connection attempt Failed "
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30758
    
156

Jonas,
Can you connect to the database through the command line?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
jonas okwara
Ranch Hand

Joined: Jun 22, 2004
Posts: 58
Thank You jeanne for your response. I already connected to the databse through the unix shell/pgsql interface. I have a java application which connected using the "//localhost/Db" entry in pg_hba.conf. but when I change it to IP Address_of_remote_host/Db, I get the errors i just posted. My troubleshooting effort started with the pg_hba.conf file.


Thanks Again


jonas okwara
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30758
    
156

Jonas,
Can you ping the remote server from the command line? It seems like there might be a firewall issue at work here.
jonas okwara
Ranch Hand

Joined: Jun 22, 2004
Posts: 58
Thanks Again Jeanne for the reply. This is a test environment i have at home and there is no firewall.

I will post my pg_hba.conf file for your review. I strongly suspect the problem is my settings in the file.


Thanks again

jonas









#pg_hba.conf file
#==========================================================
# Allow any user on the local system to connect to any database under
# any user name using Unix-domain sockets (the default for local
# connections).
#
# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD
#local all all trust

# The same using local loopback TCP/IP connections.
#
# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD
#host all all 127.0.0.1 255.255.255.255 trust
#host all 64.210.231.203 255.0.0.0 trust

# 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 testDB dbAdmin 64.210.231.203 255.0.0.0 trust

# Allow a user from host 192.168.12.10 to connect to database
# "template1" if the user's password is correctly supplied.
#
# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD
#host testApp all 205.130.237.252 255.255.255.0 md5

# In the absence of preceding "host" lines, these two lines will
# reject all connection from 192.168.54.1 (since that entry will be
# matched first), but allow Kerberos V connections from anywhere else
# on the Internet. The zero mask means that no bits of the host IP
# address are considered so it matches any host.
#
# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD
#host all all 192.168.54.1 255.255.255.255 reject
#host all all 0.0.0.0 0.0.0.0 krb5

# Allow users from 192.168.x.x hosts to connect to any database, if
# they pass the ident check. If, for example, ident says the user is
# "bryanh" and he requests to connect as PostgreSQL user "guest1", the
# connection is allowed if there is an entry in pg_ident.conf for map
# "omicron" that says "bryanh" is allowed to connect as "guest1".
#
# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD
#host all all 192.168.0.0 255.255.0.0 ident omicron

# If these are the only three lines for local connections, they will
# allow local users to connect only to their own databases (databases
# with the same name as their user name) except for administrators and
# members of group "support" who may connect to all databases. The file
# $PGDATA/admins contains a list of user names. Passwords are required in
# all cases.
#
# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD
local sameuser all md5
local all @admins md5
local all +support md5

# The last two lines above can be combined into a single line:
local all @admins,+support md5

# The database column can also use lists and file names, but not groups:
local db1,db2,@demodbs all md5
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Postgresql connection Failure