Quantcast
Channel: MySQL Forums - Connector/C++
Viewing all articles
Browse latest Browse all 527

newbie question about reusing connections (no replies)

$
0
0
I have SELECT queries that I need to run on regular intervals. I have created a sql::Connection object that I hold onto.

Every interval I generate a sql::Statement from the connection I have and run the SELECT. I then run through the result set and then delete the resultset and the statment.

The first iteration works fine, but on every next interval, when I run the SELECT I get the following error:
SQL ERROR (2014):: Commands out of sync; you can't run this command now.

This is the same query that ran fine the time before.

All the examples I have seen show the connection object being temporary to the method being called.

Is this the way it should be run? Wouldn't it be expensive to generate a connection object for every request to be run?

Thanks,
Chris

Viewing all articles
Browse latest Browse all 527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>