From: iloAda <egzgheib@gmail.com>
Subject: Re: Many Database Connections
Date: Mon, 31 Jan 2011 06:12:48 -0800 (PST)
Date: 2011-01-31T06:12:48-08:00 [thread overview]
Message-ID: <fd7a2b57-6798-4772-ad72-8c53e2c94de9@k32g2000vbn.googlegroups.com> (raw)
In-Reply-To: e493c726-542a-43e7-b02f-5239aa2eb7f2@o21g2000prn.googlegroups.com
On Jan 28, 4:22 pm, Emmanuel Briot <briot.emman...@gmail.com> wrote:
> > 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.
Thanks Emmanuel !!
It worked like a charm!!
I think that the final solution whould be a little smarter because the
final solution might very well be multithreaded!!
Thanks anyway!
ilo
prev parent reply other threads:[~2011-01-31 14:12 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
2011-01-31 14:12 ` iloAda [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox