Connection Pooling

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Thomas J.
Posts: 95
Joined: Mon 21 Nov 2005 12:16
Location: Germany

Connection Pooling

Post by Thomas J. » Fri 27 Apr 2007 12:51

Hello support,

I have read some issues regarding connection pooling, but I don't understand the way of pooling.

I have have datamodules with several TMyQuery and TMyTable component.
Now my app starts and first all datamodules open the queries and tables. (It takes some time)

Now I want to start/open all the datasets in a thread. So each datamodule in one thread.

Right now I have one component TMyConnection and set the pooling option to true.
Then I read that I have to create for each thread an instance of TMyConnection with same parameters.
So what does it mean?

Code: Select all

TMyConnection* con = new TMyConnection();
con->Server = MainCon->Server;
con->UserName = MainCon->UserName;
....
con->Connected = true;
and after all datasets are open I can delete the connection?

I found TMyConnectionPoolManager but there are only 2 methods in and I thought that I have to add the connection to the poolmanager which takes care of the connection.

thanks for your help!
Thomas

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Sat 28 Apr 2007 12:07

You should put one TMyConnection object on the each data module and set Pooling to True.
If a new data module is created and there are unused connections in the pool, MyConnection will take a connection from the pool. Otherwise, it will cerate a new connection.

Thomas J.
Posts: 95
Joined: Mon 21 Nov 2005 12:16
Location: Germany

Post by Thomas J. » Mon 30 Apr 2007 06:12

Your are talking from a pool, but where is the pool? Who creates this pool?
Thanks for your help

swierzbicki
Posts: 451
Joined: Wed 19 Jan 2005 09:59

Post by swierzbicki » Mon 30 Apr 2007 18:32

MyDac is creating and automatically handling the pool

Thomas J.
Posts: 95
Joined: Mon 21 Nov 2005 12:16
Location: Germany

Post by Thomas J. » Tue 01 May 2007 10:56

So that means if I put 2 components of TMyConnection in my project and set the pooling = true (All connection settings same) pooling is done already?

Set would be great!

Thanks,
Thomas

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Thu 03 May 2007 07:21

Yes, these settings are enough to setup pooling.

Post Reply