List:MySQL++« Previous MessageNext Message »
From:Doug Morrow Date:January 3 2011 8:55am
Subject:Problem with Connection Pointers and Stored Procedures
View as plain text  
I'm having a problem currently with my C++ application.  I'm trying to
convert it to using a ConnectionPool, however, regardless of whether I
do, I cannot receive result sets from stored procedures as long as the
connection is a pointer.

So to simplify things, here's the bare-bones code of what's going on
just using a pointer to a connection object.

		mysqlpp::StoreQueryResult res;
		std::stringstream ss (std::stringstream::in | std::stringstream::out);
		mysqlpp::Connection* conn = new mysqlpp::Connection(false);

		ss << "CALL `Somnium`.`" << SPName << "`(";
		
		for(unsigned int i = 0; i < argc;i++)
		{
			ss << arga[i];
			if( i < argc - 1)
			 ss << ", ";
		}
		
		ss << ")";
		char* qstring = new char[256];
		ss.getline( qstring, 256 );
		
		std::cout << qstring << std::endl;
		if (conn->connect("Somnium", "localhost", "Somnium", "password"))
		{
			mysqlpp::Query query(conn->query((const char*)qstring));
			try{

				if(conn->set_option(new mysqlpp::MultiStatementsOption(true)))
					std::cout << "MultiStatements Set" << std::endl;
				else
					std::cout << "MultiStatements NOT Set" << std::endl;

				if(conn->set_option(new mysqlpp::MultiResultsOption(true)))
							std::cout << "MultiResults Set" << std::endl;
						else
							std::cout << "MultiResults NOT Set" << std::endl;
				if (!(res = query.store()))
					std::cerr << "StoredProcedure Call Failed(" << SPName << "): "
<< query.error() << std::endl;
			}
			catch(mysqlpp::Exception e)
			{
				std::cerr << "mysql++ exception thrown: " << e.what() << std::endl;
			}
		}

Console output is:

CALL `Somnium`.`LookupAccounts`()
MultiStatements Set
MultiResults Set
StoredProcedure Call Failed(LookupAccounts): PROCEDURE
Somnium.LookupAccounts can't return a result set in the given context

This works fine if I revert the connection object to a static one.
Please note this does seem like overkill in the given context, however
this was just generated to simplify and identify the problem.

Any and all help will be greatly appreciated!
Thread
Problem with Connection Pointers and Stored ProceduresDoug Morrow3 Jan
  • Re: Problem with Connection Pointers and Stored ProceduresWarren Young3 Jan
    • Re: Problem with Connection Pointers and Stored ProceduresTomalak Geret'kal3 Jan
    • Re: Problem with Connection Pointers and Stored ProceduresDoug Morrow4 Jan
      • Re: Problem with Connection Pointers and Stored ProceduresWarren Young4 Jan
      • Re: Problem with Connection Pointers and Stored ProceduresDoug Morrow4 Jan
        • Re: Problem with Connection Pointers and Stored ProceduresChris Morgan4 Jan
          • Re: Problem with Connection Pointers and Stored ProceduresDoug Morrow4 Jan