dbTalk Databases Forums  

Re: Proper use of the Connection object and how to handle many queries

mailing.database.mysql-plusplus mailing.database.mysql-plusplus


Discuss Re: Proper use of the Connection object and how to handle many queries in the mailing.database.mysql-plusplus forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Warren Young
 
Posts: n/a

Default Re: Proper use of the Connection object and how to handle many queries - 11-15-2005 , 03:23 PM






Steve Povilaitis wrote:
Quote:
Most exalted ones,
Yes, O kneebiting supplicant?

Quote:
Is it better/preferred to instantiate one Connection object and then pass
this object to different parts of the client application that need to
execute queries, then close the connection when the application terminates?
Or should one instantiate a new connection object in each method that
executes a query or whatever, then close it when finished?
Connection establishment takes a fair bit of time, especially if you're
using a database server on a separate machine.

The only good reason to have more than one Connection per process is if
you are using threads, or in some other way multiplexing access to the
database. This is because the MySQL C API does not allow certain
operations to be overlapped. (RTFM for the details.) Other than
threads, there aren't very many sane ways for this to happen.

Quote:
Related, Is it necessary to explicitly call close() on a connection?
Not in common use. Connection's dtor calls it for you.

This method only exists in case you want to close and then re-establish
the underlying database connection without recreating the Connection object.

Quote:
I'm using the data access object pattern and have a DAO class
Please provide a reference. The only DAO I know is Microsoft's database
access technology (one of the many they've pushed over the years,
anyway) which wouldn't be on topic here.

Quote:
It appears that I might be overloading the abilities of something, because
my app crashes when the network traffic goes really high and causes a huge
number of calls to my DAO insert() method.
Is it crashing within MySQL++? If so, can you provide a stack trace?
What platform are you using?

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.