Please take our Survey
logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

Re: Proper use of the Connection object and how to handle many queries in a: msg#00078

db.mysql.c++

Subject: Re: Proper use of the Connection object and how to handle many queries in a short time

Steve Povilaitis wrote:
Most exalted ones,

Yes, O kneebiting supplicant?

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.

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.

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.

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?unsub=gcdmc-plusplus@xxxxxxxxxxx




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
solaris.opensol...    editors.vim/200...    web.turbogears....    jakarta.ant.dev...    mathematics.max...    text.unicode.ge...    lang.ruby.core/...    xfce.announce/2...    network.centeri...    php.cvs.pear/20...    user-groups.lin...    kde.devel.quant...    file-systems.ar...    redhat.fedora.t...    apple.fink.auto...    gnome.orbit.gen...    qplus.devel/200...    culture.transpo...    video.dri.user/...    operators.nanog...   
Home | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe

Navigation