Subject | Re: Multi threaded access using in objects |
---|---|
Author | williamvdw2004 |
Post date | 2004-06-29T06:28:43Z |
--- In IBObjects@yahoogroups.com, "gbehnke2000" <Behnke@h...> wrote:
It is working now!!! Thank you! Thank you!
> William,the
>
> in addition to that whas helen wrote it's very importend that you
> create the TIB_Connection, Session and Transaction Object not in
> constructor of your Threadobject but instead in the execute methodemissing
> of the Threadobject. The Constructor runs in the same address space
> like the main thread.
>
> Regards
> Gerhard
>
> --- In IBObjects@yahoogroups.com, Helen Borrie <helebor@t...> wrote:
> > At 12:02 PM 28/06/2004 +0000, you wrote:
> > >I have seen some posts on this subject.
> > >1. I need an explisit session.
> > >2. prorocol : cpTCP_IP
> > >3. Server : 127.0.0.1
> > >
> > >This code is inside the constructor of the thread. What is
> > >please.need
> > >
> > > FSession := TIB_Session.Create(nil);
> >
> > > FConnection := TIB_Connection.CreateForSession(nil,FSession);
> >
> > Don't use CreateForSession: it has another purpose. And don't use
> nil
> > owners for anything but the TIB_Session.
> > FConnection := TIB_Connection.Create(FSession);
> >
> > > FConnection.Protocol := cpTCP_IP;
> > > FConnection.Server := '127.0.0.1';
> >
> > not
> > > FQuery := TIB_Query.CreateForSession(nil,FSession);
> >
> > but
> > FQuery := TIB_Query.Create(FSession);
> >
> > > FQuery.IB_Connection := FConnection;
> >
> > Either
> > FQuery.IB_Transaction := FConnection.ib_transaction;
> >
> > or, better, declare an explicit IB_Transaction (FTransaction :=
> > TIB_Transaction.Create(FSession);
> > FTransaction.[..........properties...........]
> > FTransaction.IB_Connection := FConnection;
> >
> > then
> > FQuery.IB_Transaction := FConnection;
> >
> > > FConnection.DatabaseName := 'c:\test.gdb';
> >
> > Wrong here. You want
> >
> > FConnection.Path := 'c:\test.gdb';
> >
> > (DatabaseName would be '127.0.0.1:c:\test.gdb' but IBO doesn't
> it)In susequent threads it crashed on the connect line. But...
> >
> > > FConnection.Username := 'SYSDBA';
> > > FConnection.Password := 'masterkey';
> > > FConnection.Connect;
> > >
> > >The thread breaks on the fquery.execute line.
> >
> > Something is missing here:
> > with FQuery do
> > begin
> > if not IB_Transaction.Started then
> > ib_Transaction.StartTransaction;
> > SQL.Add('a statement');
> > if not Prepared then Prepare;
> > Params[n].AsWhatever := something;
> > ...
> > Execute;
> > end;
> >
> > What are you executing? TIB_Query is for SELECT statements. Use
> > TIB_Cursor or TIB_DSQL for executable statements.
> >
> > >When I create only one thread the code works fine.
> >
> > What happens when subsequent threads run?
> >
> > Helen
It is working now!!! Thank you! Thank you!