[Gambas-user] how to override Exec if already inherist from colection (conection pool emulation)

PICCORO McKAY Lenz mckaygerhard at gmail.com
Fri Jul 6 16:24:52 CEST 2018


2018-07-05 9:44 GMT-04:00 Christof Thalhofer <chrisml at deganius.de>:
> This is annoying (and not very elegant) if you have to use a lot of
> connections in your program, because you always have to write sth like
> "conex2" by hand.
i want something like the DB connection naming service by oracle in
Java! https://docs.oracle.com/cd/B28359_01/java.111/b31224/urls.htm#BEIDHCBA

Of course less complicated! using statics names and developer just
need to modify parameters, no code modifications need!

but i like your idea, i can set a "Conex" property that choose a db
name from the AllDbs pool, and have a factory that loop over the
configuration file

i'll try to do something with your class and report feedback later
>
> If you do not use too much databases (say, up to 50) you could do it
> better using a static class with connections as properties, like in the
> example class I attached.
>
> Then you do not need to dim any connection and you can do sth simple like
>
> Dbs.Conex1.Exec(sQuery)
>
> Dbs.Conex2.Exec(sQuery)
>
> anywhere in your program without the need to Dim it.
>
> Also every connection exists just one time and lives as long as your
> program runs, this is very cool as it avoids the creation of multiple
> similar connections to the same db which can easily lead to deadlocks.
>
>
> Alles Gute
>
> Christof Thalhofer
>
> --
> [x] nail here for new monitor
>
>
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>


More information about the User mailing list