I'm trying to connect to a PgBouncer-guarded database but it's causing a TPgException with message '' (empty string).
I'm using the following implementation:
Code: Select all
const
CONNECTSTR = 'Password=%s;User ID=%s;DATABASE=%s;SERVER=%s;PORT=%s;UID=%s;'+
'PWD=%s;UseUnicode=True;CharSet=WIN1252';
...
procedure TfrmProtoPgDacConnection.Button1Click(Sender: TObject);
function Cfg(const aConfigName: string): string;
begin
Result := mmoConfig.Lines.Values[aConfigName];
if Result = '' then
raise Exception.Create('Configuration not found: ' + aConfigName);
end;
var
_Conn : TPgConnection;
begin
_Conn := TPgConnection.Create(nil);
try
_Conn.ConnectString := Format(CONNECTSTR,[Cfg('Password'),
Cfg('User_Name'), Cfg('Database'), Cfg('Server'),
Cfg('Port'), Cfg('User_Name'), Cfg('Password')]);
_Conn.ProtocolVersion := pv20;
_Conn.ConnectionTimeout := 30;
_Conn.Pooling := False;
_Conn.Connected := True;
ShowMessage('Connection successful');
finally
_Conn.Connected := False;
_Conn.Free;
end;
end;
Code: Select all
auth_type = md5
...
pool_mode = transaction
default_pool_size = 15
reserve_pool_size = 10
server_reset_query = DISCARD ALL
server_reset_query_always = 1
- It happens the same way in version 4.6.20 and 5.2 trial.
- It works correctly when connecting directly to the database.
- We need PgBouncer to be in transaction mode.
- pgAdmin3 can connect and work through our PgBouncer normally, using the same connection configurations.
- When I use pv30 the error message is like this: 'prepared statement "PRSTMTST733962560" does not exist'.
- Problem happens in Delphi XE, XE3 and Tokyo (all fully patched).
Thank you.