FireDAC + EntityDAC + DataSnap

Discussion of open issues, suggestions and bugs regarding EntityDAC
claudio.piffer
Posts: 48
Joined: Mon 30 Apr 2007 07:36

FireDAC + EntityDAC + DataSnap

Post by claudio.piffer » Thu 19 Feb 2015 21:21

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

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

Re: FireDAC + EntityDAC + DataSnap

Post by AlexP » Fri 20 Feb 2015 10:00

Hello,

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

claudio.piffer
Posts: 48
Joined: Mon 30 Apr 2007 07:36

Re: FireDAC + EntityDAC + DataSnap

Post by claudio.piffer » Fri 20 Feb 2015 10:37

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;

claudio.piffer
Posts: 48
Joined: Mon 30 Apr 2007 07:36

Re: FireDAC + EntityDAC + DataSnap

Post by claudio.piffer » Fri 20 Feb 2015 16:43

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

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

Re: FireDAC + EntityDAC + DataSnap

Post by AlexP » Fri 20 Feb 2015 16:55

Glad to see that the issue was resolved. If you have any further questions, feel free to contact us.

elion
Posts: 29
Joined: Wed 10 Dec 2014 07:15

Re: FireDAC + EntityDAC + DataSnap

Post by elion » Mon 08 Aug 2016 08:27

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!

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

Re: FireDAC + EntityDAC + DataSnap

Post by AlexP » Mon 08 Aug 2016 11:14

Thank you for the information. We have reproduced the issue when using pooling and will try to fix this behavior shortly.

elion
Posts: 29
Joined: Wed 10 Dec 2014 07:15

Re: FireDAC + EntityDAC + DataSnap

Post by elion » Mon 08 Aug 2016 14:50

You are welcome, it would be great to get an update shortly! I need actually this code already yesterday :D :wink:

elion
Posts: 29
Joined: Wed 10 Dec 2014 07:15

Re: FireDAC + EntityDAC + DataSnap

Post by elion » Tue 09 Aug 2016 05:48

Hello Alex,

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

Best regards,
pst

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

Re: FireDAC + EntityDAC + DataSnap

Post by AlexP » Tue 09 Aug 2016 08:05

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.

elion
Posts: 29
Joined: Wed 10 Dec 2014 07:15

Re: FireDAC + EntityDAC + DataSnap

Post by elion » Tue 09 Aug 2016 08:24

Great! :D Where can I get this update?

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

Re: FireDAC + EntityDAC + DataSnap

Post by AlexP » Tue 09 Aug 2016 08:54

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 .

elion
Posts: 29
Joined: Wed 10 Dec 2014 07:15

Re: FireDAC + EntityDAC + DataSnap

Post by elion » Tue 09 Aug 2016 09:19

Our IT service company will send you a request to get the last night build. Thank you very much!

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

Re: FireDAC + EntityDAC + DataSnap

Post by AlexP » Wed 10 Aug 2016 06:33

send by mail

elion
Posts: 29
Joined: Wed 10 Dec 2014 07:15

Re: FireDAC + EntityDAC + DataSnap

Post by elion » Wed 10 Aug 2016 15:22

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!

Post Reply