Database connection problem

Discussion of open issues, suggestions and bugs regarding PgDAC (PostgreSQL Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
AlexK
Posts: 8
Joined: Sun 29 May 2011 06:40

Database connection problem

Post by AlexK » Sun 29 May 2011 08:09

Trying to connect in TPgConnection to server I receive "Cannot connect to database. Socket error on connect. WSAGetLast Error return 10060($274C)".

Serve definition is suspected. Any ideas? What is the Error meaning?

Thank you in advance...

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Mon 30 May 2011 09:00

Hello,

Please specify the following information:
the exact version of PgDAC;
the exact version of the PostgreSQL server;
the exact version of your IDE.

Also please check that you specified all connection parameters correctly and you can connect to the server with the help of any third-party components, for example, PgAdmin.

AlexK
Posts: 8
Joined: Sun 29 May 2011 06:40

Post by AlexK » Mon 30 May 2011 12:05

Hi AlexP,

Thank you for your response.

Please, specify how I can get PgDAC and IDE version.

I use Delphi 6, build 6.240 and Postgre SQL 9.0 for win x64.

I succeed to connect to local server with Postgre SQL 9.0 x32 and hope that parameters for connection are correct.

Is it possible to get explanations for Errors?

Thank you in advance...

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Mon 30 May 2011 13:27

Hello,

You can find the exact version of PgDAC at the About tab of the PgConnection component.
As I have already written, please check if you can connect to your PostgreSQL x64 server using the standard PgAdmin utility. If you can connect using PgAdmin, you should use the same settings in PgDAC. If you cannot connect, contact your database administrator and ask him what are the exact parameters for connecting to the remote server.

You can get the description of the error by executing the following code:

Code: Select all

ShowMessage(SysErrorMessage(ErrCode));
Where ErrCode is the error code (in your case it is 10060: 'A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond')

AlexK
Posts: 8
Joined: Sun 29 May 2011 06:40

Post by AlexK » Mon 30 May 2011 14:15

Hi AlexP,

I appreciate you immediate response!!! :D

I could not find About Tab on the Components, but the version of "pgdac60.bpl" is 2.20.0.6. (Sorry, sometimes I become stupid....)

Connection to Postgre SQL from the local PgAdmin is simple and successful.
The same parameters does not help from remote.
I suspect a problem in pg_hba.conf. I have the next:


# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
host all all 192.168.1.0/0 md5

and hope it work, but no....

Thank you for tip with "LastError" explanation...

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Mon 30 May 2011 14:42

Hello,

Check that the following lines are defined in the file like:

in postgresql.conf

listen_addresses = '*'

in pg_hba.conf

# IPv4 local connections:
host all all 192.168.1.0/24 trust

AlexK
Posts: 8
Joined: Sun 29 May 2011 06:40

Post by AlexK » Tue 31 May 2011 07:06

Hi Alex,

Unfortunately, it does not help.

Postgresql.conf contains the line required.
Line added to pg_hba.conf didn't change anything...

I'll try to talk with our Net Admin...

Is it possible to use some other postgre tools to try remote connection?

Thank you,
Alex.

AlexK
Posts: 8
Joined: Sun 29 May 2011 06:40

Post by AlexK » Tue 31 May 2011 07:46

Hi Alex,

Maybe, the problem is that remote server is Windows 7 with Postgre SQL 9.0 for x64.
Client that I try to connect is 32 bit application from Windowa XP.

Are there any limitation between x-32 and x64 connections? Is it possible?

Now I'm installing Postgre server on the Windows XP computer for tests...

AlexK
Posts: 8
Joined: Sun 29 May 2011 06:40

Post by AlexK » Tue 31 May 2011 08:45

Hi Alex,

Sorry, it's me again...
I installed Postgre SQL 32 bit on Windows XP. And created the same Server with DB as on local.
Attempt to connect follows message "Cannot connect to database no pg_hba.conf entry for host "192.168.0.150", user "xxx", database "yyy", SSL off". Server IP is 192.168.1.142..

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Tue 31 May 2011 08:45

Hello,

To check connection to the PostgreSQL server, it's better to use the standard PgAdmin utility that is available in the PostgreSQL installation. You can also download it separately from the developers' site.

As PgDAC does not use the PostgreSQL client to work with server, OS capacity and version as well as those of PostgreSQL do not have any meaning.

PgDAC working capacity was tested on most OSs and PostgreSQL servers.

AlexK
Posts: 8
Joined: Sun 29 May 2011 06:40

Post by AlexK » Tue 31 May 2011 09:49

Hi Alex,

Thank you for your response.
I already succeeded to connect remote Postgre SQL server on Windows XP. The problem was in pg_hba.conf...
Continue with Win 7 64 bit...

Thank you for support...

yapt
Posts: 69
Joined: Mon 16 Mar 2009 12:06

Post by yapt » Mon 06 Jun 2011 19:51

I connect fine to my Windows 7 with PostgreSQL 9.0 x64 from a Windows Vista client x32.

Greetings..

AlexK
Posts: 8
Joined: Sun 29 May 2011 06:40

Post by AlexK » Thu 16 Jun 2011 09:56

It was firewall in local network domain. No problem between Windows XP and Windows XP, but error received during connection between Windows XP and Window 7 64 bit.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Tue 21 Jun 2011 08:37

Hello,

As PgDAC does not use PostgreSQL client for connecting and works with server directly through the network TCP/IP protocol, the problem seems to be connected with the firewall settings (some ports may be closed or access from definite addresses may be forbidden, etc). Try to turn the firewall off and connect to the PostgreSQL server once more.

Post Reply