Have you checked the mysql++ documentation? It's answered there.
http://tangentsoft.net/mysql++/doc/h...n/threads.html
Have you checked the mysql++ documentation? It's answered there.
http://tangentsoft.net/mysql++/doc/h...n/threads.html
You should guard against unforeseen failures. For example:
The link provided by Some Penguin offers good advice on this subject.Code:try { mysqlpp::Connection dbconn(database.c_str(), host.c_str(), user.c_str(), password.c_str()); mysqlpp::Query query = dbconn.query(); mysqlpp::StoreQueryResult result = query.store(thequery.c_str()); if (result) { doSomethingWithResult(result); while (query.more_results()) { doSomethingWithResult(query.store_next()); } } else { // some queries do not return results; yet by being here // we know that the query was successful. } } catch (std::exception& e) { std::cerr << "Caught exception: " << e.what() << std::endl; }
I replaced libmysqlclient.so with libmysqlclient_r.so and now it's working fine! No change in mysqlpp code or my code in using mysqlpp. What's the difference between 2 these files?!!!
Thanks b4
It seems that you did not read the documentation carefully enough.
Did you not read about the ConnectionPool? You had better be using that too, since from what you described earlier, you have lots of connections in many different threads.If you use a binary distribution of MySQL on Unixy systems, you usually get two different versions of the MySQL C API library, one with thread support and one without. These are typically called libmysqlclient and libmysqlclient_r, the latter being the thread-safe one. (The “_r” means reentrant.)
Bookmarks