Page 1 of 2

FireDAC + EntityDAC + DataSnap

Posted: Thu 19 Feb 2015 21:21
by claudio.piffer
Hi,

How I can configure TEntityConnection to use a pooled connection (SQLServer 2014) with FireDAC + EntityDAC in a Datasnap REST application?

Thank you very much

Best Regads

Claudio

Re: FireDAC + EntityDAC + DataSnap

Posted: Fri 20 Feb 2015 10:00
by AlexP
Hello,

If FireDAC supports such functionality, and these parameters can be set in ConnectionString, you can set a corresponding ConnectionString for dEntityConnection

Re: FireDAC + EntityDAC + DataSnap

Posted: Fri 20 Feb 2015 10:37
by claudio.piffer
Hi Alex

thank you very much for your answer. The problem is that FireDAC allows pooled connection only in Persistent and Private connections definition.

In FDConnection I must use the ConnectionDefName property and not ConnectionString, but I cannot associate ConnectionDefName to a connectionstring property in TEntityConnection.

Here the FireDAC sample:

var
oParams: TStrings;
begin
oParams := TStringList.Create;
oParams.Add('Database=ORA_920_APP');
oParams.Add('User_Name=ADDemo');
oParams.Add('Password=a');
oParams.Add('Pooled=True');
FDManager.AddConnectionDef('Oracle_Pooled', 'Ora', oParams);
.....................
FDConnection1.ConnectionDefName := 'Oracle_Pooled';
FDConnection1.Connected := True;

Re: FireDAC + EntityDAC + DataSnap

Posted: Fri 20 Feb 2015 16:43
by claudio.piffer
Hi Alex,

sorry, you are right! Problem solved! I can set this in ConnectionString of the TEntityConnection component.

Best regards and thank you very much

Re: FireDAC + EntityDAC + DataSnap

Posted: Fri 20 Feb 2015 16:55
by AlexP
Glad to see that the issue was resolved. If you have any further questions, feel free to contact us.

Re: FireDAC + EntityDAC + DataSnap

Posted: Mon 08 Aug 2016 08:27
by elion
Hi there,

I am working with EntityDAC+FireDAC+MySQL and I have a problem with the parameter Pooled in TEntityConnection.ConnectionString. If I set this parameter to False, everything is fine, but if I set it to True, then I get a FireDAC error something like "the connection is not in FDManager.ConnectionDefs-list or TFDConnection.Params has additional parameters".

Then, I looked into the unit EntityDAC.DataProvider.FireDAC
I put the following code into the method TFireDACConnectionProvider.DoConnect

Code: Select all

procedure TFireDACConnectionProvider.DoConnect;
var
  ConDef: IFDStanConnectionDef;
begin
  inherited;

  if FDManager.ConnectionDefs.FindDefinition('MyConnectionName') = nil then
  begin
    ConDef := FDManager.ConnectionDefs.AddConnectionDef;
    ConDef.Name := 'MyConnectionName';
    ConDef.Params.Pooled := True;
    ConDef.Params.PoolMaximumItems := 500;
    ConDef.Params.Database := 'mydatabase';
    ConDef.Params.UserName := 'myUserName';
    ConDef.Params.Password := 'MyPassoword';
    ConDef.Params.Add('Port=3306');
    ConDef.Params.Add('Server=localhost');
    ConDef.Params.DriverID := 'MySQL';
    ConDef.MarkPersistent;
    ConDef.Apply;
  end;

  FFDConnection.ConnectionDefName := 'MyConnectionName';
  FFDConnection.Open;
end;
With this code EntityDAC can do the FireDAC connection pooling. But the disadvantage I have to hack the EntityDAC-Units. Is there any possibility to get the funtionality without this hack? :-)

Thank you!

Re: FireDAC + EntityDAC + DataSnap

Posted: Mon 08 Aug 2016 11:14
by AlexP
Thank you for the information. We have reproduced the issue when using pooling and will try to fix this behavior shortly.

Re: FireDAC + EntityDAC + DataSnap

Posted: Mon 08 Aug 2016 14:50
by elion
You are welcome, it would be great to get an update shortly! I need actually this code already yesterday :D :wink:

Re: FireDAC + EntityDAC + DataSnap

Posted: Tue 09 Aug 2016 05:48
by elion
Hello Alex,

how do you think, how much time would devart need to fix this problem? Thank you!

Best regards,
pst

Re: FireDAC + EntityDAC + DataSnap

Posted: Tue 09 Aug 2016 08:05
by AlexP
We have added a ConnectionDefName parameter for FireDAC. Now, to use Pooled or other additional connection parameters, you should create ConnectionDefs with corresponding parameters (in the code or using FireDAC Explorer), and specify the connection name as follows:

Code: Select all

EntityConnection1.ConnectionString := 'Data Provider=FireDAC;SQL Dialect=MySQL;Login Prompt=False;ConnectionDefName=MySQLTest'
where MySQLTest is the name of the created connection.

Re: FireDAC + EntityDAC + DataSnap

Posted: Tue 09 Aug 2016 08:24
by elion
Great! :D Where can I get this update?

Re: FireDAC + EntityDAC + DataSnap

Posted: Tue 09 Aug 2016 08:54
by AlexP
We can send you a night build in order for you to check this case on your sample. For this, please send your license number to support*devart*com .

Re: FireDAC + EntityDAC + DataSnap

Posted: Tue 09 Aug 2016 09:19
by elion
Our IT service company will send you a request to get the last night build. Thank you very much!

Re: FireDAC + EntityDAC + DataSnap

Posted: Wed 10 Aug 2016 06:33
by AlexP
send by mail

Re: FireDAC + EntityDAC + DataSnap

Posted: Wed 10 Aug 2016 15:22
by elion
Hi Alex,

thx for the email. My test failed :-(

Code: Select all

EMySQLNativeException: [FireDAC][Phys][MySQL] Access denied for user 'ODBC'@'localhost' (using password: NO)
I used the folowing code in my main application:

Code: Select all


  FDManager.ConnectionDefFileAutoLoad := False;
  if FDManager.ConnectionDefs.FindDefinition('MyConnectionName') = nil then
  begin
    ConDef := FDManager.ConnectionDefs.AddConnectionDef;
    ConDef.Name := 'MyConnectionName';
    ConDef.Params.Pooled := True;
    ConDef.Params.PoolMaximumItems := 500;
    ConDef.Params.Database := 'mydatabase';
    ConDef.Params.UserName := 'myUserName';
    ConDef.Params.Password := 'MyPassoword';
    ConDef.Params.Add('Port=3306');
    ConDef.Params.Add('Server=localhost');
    ConDef.Params.DriverID := 'MySQL';
    ConDef.MarkPersistent;
    ConDef.Apply;
  end;

  EntityConnection1.ConnectionString := 'Data Provider=FireDAC;SQL Dialect=MySQL;Login   Prompt=False;ConnectionDefName=MyConnectionName'
In the provider the commented commands are empty

Code: Select all

procedure TFireDACConnectionProvider.DoConnect;
begin
  inherited;
//  FFDConnection.ConnectionDefName  --> empty
//  FFDConnection.Params.UserName  --> empty
//  ...
  FFDConnection.Open;
end;
Thx for your help!