471,603 Members | 1,581 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,603 software developers and data experts.

sqlite static database connection over multiple instances

hi

I want to wrap the access to a sqlite database in an object. So i can
create multiple instances of this wrapper with base code to get data
out of the sqlite database.

But i want to make the connection only onces when i create the first
instance. And when the program ends the connection should be removed.

ex.

wrapper objects

query wrapperQuery1 = new query(); // here the database should connect
query wrapperQuery2 = new query(); // connection should already exists
query wrapperQuery3 = new query(); // connection should already exists

wrapperQuery1.close(); // dbconnect stays open
wrapperQuery3.close(); // dbconnect stays open
wrapperQuery2.close(); // dbconnect should close now when.

How would i contruct this?
Nov 29 '05 #1
1 3407
Digital Fart,

That's a REALLY bad way of handling this. Basically, when you perform
your query, you should open the connection, perform the operation, and close
it.

Database connections are the kind of resources that degrade over time,
and also are limited in use (if you have one being sucked up, that's one
less connection that can be made to the database).

My advise is to open the connection and close it when you are done with
the query.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Digital Fart" <pr*********@angelfire.com> wrote in message
news:c2********************************@4ax.com...
hi

I want to wrap the access to a sqlite database in an object. So i can
create multiple instances of this wrapper with base code to get data
out of the sqlite database.

But i want to make the connection only onces when i create the first
instance. And when the program ends the connection should be removed.

ex.

wrapper objects

query wrapperQuery1 = new query(); // here the database should connect
query wrapperQuery2 = new query(); // connection should already exists
query wrapperQuery3 = new query(); // connection should already exists

wrapperQuery1.close(); // dbconnect stays open
wrapperQuery3.close(); // dbconnect stays open
wrapperQuery2.close(); // dbconnect should close now when.

How would i contruct this?

Nov 29 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Mudge | last post: by
15 posts views Thread by RichGK | last post: by
2 posts views Thread by Christian Stooker | last post: by
reply views Thread by Jim Stools | last post: by
4 posts views Thread by Varangian | last post: by
6 posts views Thread by Rob Stevens | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by CCCYYYY | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.