Subject Re: [IBO] Connection pooling ??? How to do it???
Author Jason Wharton
This looks like a great candidate for a FAQ entry.
Give this a go and let us know how it works.
As far as I can tell, you are using it just how I intended.

Regards,
Jason Wharton
CPS - Mesa AZ
http://www.ibobjects.com

-- We may not have it all together --
-- But together we have it all --


----- Original Message -----
From: "Michael L. Horne" <guardian@...>
To: <IBObjects@yahoogroups.com>
Sent: Friday, September 06, 2002 3:28 PM
Subject: [IBO] Connection pooling ??? How to do it???


> Hello,
>
> First a description of what I am attempting to do.
> I am writing a small web server, and I need to access
> Interbase to supply the information for the various
> web pages. I am of course going to use threads to
> allow multiple access.
>
> The problem is in how to do something like connection
> pooling of the TIB_Connection. So I can have a
> connection for each thread but not have the overhead
> of creating and connecting each time a page is called.
> I scanned the old messages and saw a reference to
> "DisconnectToPool". That sounds great, but what does
> it actually do?
>
> Sounds like it stores the handle and next time I
> try to connect it reuses the handle (if available) or
> creates a new one if not. This sounds like it would
> be easy to use and much faster than doing a connection
> each time. I assume I would still create IB_Sessions
> and so forth.
>
> I assume the code in the thread will be something like:
>
> =================================================
> vars ibSession:TIB_Session;
> ibConnection:TIB_Connection;
> begin
> ibSession := TIB_Session.Create(nil);
> try
> ibConnection := TIB_Connection.Create(ibSession);
> try
> ibConnection.DatabaseName := xFileName;
> ibConnection.UserName := xUserName;
> ibConnection.Password := xPassword;
> ibConnection.Connect;
> try
> ----- Do some processing here -----
> finally
> ibConnection.DissconnectToPool;
> end;
> finally
> ibConnection.Free;
> end;
> finally
> ibSession.Free;
> end;
> =================================================
>
> Is this somewhat like I should do it??????
>
> Please feel free to explain and expand.
>
> Thanks
> Michael L. Horne