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?