Subject | Re: [IBO] Some help with thread-safe access |
---|---|
Author | Andreas Hesse |
Post date | 2008-02-06T07:51:53Z |
A Connection pool is a collection of allready connected Connections
(Session and Transactions and perhaps Cursors), that you can use in a
thread.
If you use one connection of a pool you check it out (mark it as
reserved). After using you put it back to the pool (mark it as free for
using).
You do everything with a connection pool manager.
It will create more connections if every connection is in use.
Normally until the maximum number of connections is reached.
Java has some inbuild classes for connection pooling.
@Jason (@Helen): Is there anything in IB Object for pooling?
Thats my short explanation of a pool.
Andreas
(Session and Transactions and perhaps Cursors), that you can use in a
thread.
If you use one connection of a pool you check it out (mark it as
reserved). After using you put it back to the pool (mark it as free for
using).
You do everything with a connection pool manager.
It will create more connections if every connection is in use.
Normally until the maximum number of connections is reached.
Java has some inbuild classes for connection pooling.
@Jason (@Helen): Is there anything in IB Object for pooling?
Thats my short explanation of a pool.
Andreas
> Thanks Andreas,
>
> Well, I think creating and tearing down all those database components on each inbound message (because i need to use this approach in OnExecute event too) is a bit overkill. Connection pool it is interesting, but I never used. Can you give me an little example code of how to use connection pool ? Please, Please.
>
> Thx
> Alexandre
> Brazil
>
>
>
> > Hi Guys,
> >
> > Please a need a help,
> >
> > I need make a application with TIDTcpServer, TIDTcpClient and IBO, but a have a question.
> >
> > I need do this:
> >
> > 1- I have to connect to server and pass a user name
> > 2- With this user name, using TIB_Cursor to find the full name of user in my table
> > 3- Return the name to the client program.
> >
> > I dont know how do this whit IBO because OnConnect event in TIDTcpServer is mult-thread. The access to the TIB_Cursor must be thread-safe
> >
> > How do This
> >
> > Exemple:
> >
> >
> > TMyContext = class(TIdContext)
> > public
> > username: string;
> > end;
> >
> > OnConnect event:
> >
> > procedure TForm1.IdTCPServer1Connect(AContext: TIdContext);
> > begin
> >
> > with TMyContext(AContext) do
> > begin
> > username:= strtoint(Connection.IOHandler.ReadLn);
> > if (username<> '') then
> > begin
> > ////////////////////////
> >
> > I need make the select here with TIB_Cursor. 'Select fullname from mytable where user=username'
> >
> > but I dont know how make this access being thread-safe for each connection...please help me
> >
> > /////////////////////
> > Connection.IOHandler.WriteLn(fullname);
> > end
> > else
> > begin
> > Connection.IOHandler.WriteLn('error');
> > Connection.Disconnect;
> > end;
> > end;
> > end;
> >
> > Thx for some help
> >
> > Alexandre
> > Brazil
> >
>
> Create a IB_Connection (perhaps a IB_Session too) and the IB_Cursor
> just in place und use it.
> Or for quicker access use a connection pool.
>
> Andreas
>
>
>
>