comp.lang.ada
 help / color / mirror / Atom feed
From: Emmanuel Briot <briot.emmanuel@gmail.com>
Subject: Re: Many Database Connections
Date: Fri, 28 Jan 2011 07:22:06 -0800 (PST)
Date: 2011-01-28T07:22:06-08:00	[thread overview]
Message-ID: <e493c726-542a-43e7-b02f-5239aa2eb7f2@o21g2000prn.googlegroups.com> (raw)
In-Reply-To: df7d3afd-ea0d-4394-9d6f-193c494dfdb5@n18g2000vbq.googlegroups.com

> I do use the Get_Task_Connection to create the connection, and I've
> looked into the GNATCOLL library and it seems to me that it has a
> global variable (DB_Attributes) that holds some info about the DB, the
> first call to the Get_Task_Connection function will give a value to
> DB_Attributes, and all subsequent calls to the Get_Task_Connection
> function will return the value of DB_Attributes, even if we try to
> connect to a new Database (The only solution I found till now is to
> open a connection, insert values then directly close the connection,
> but this isn't a good practice!)

DB_Attributes is not a global variable (I don't think gnatcoll is
using any such variable).
It is a package which allows us to store task attributes (ie for each
task we store which is the associated connection -- to match the
semantics of Get_Task_Connection).
So indeed the second call to Get_Task_Connection will return the first
connection, since you have a single task.
In your case, you do not want to use Get_Task_Connection since you
want multiple connections in the same task.

So use something like:

  DB1 := Connection_Factory (DB1_Descr);
  Reset_Connection (DB1, DB1_Descr);
  DB2 := Connection_Factory (DB2_Descr);
  Reset (DB2, DB2_Descr);

and then you have two independent connections that you should be able
to use from the same thread.






  reply	other threads:[~2011-01-28 15:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-27 17:00 Many Database Connections Elie Zgheib
2011-01-27 21:37 ` Emmanuel Briot
2011-01-28 12:10   ` iloAda
2011-01-28 15:22     ` Emmanuel Briot [this message]
2011-01-31 14:12       ` iloAda
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox