MySQL Forums
Forum List  »  Connector/C++

Connector/C++ MySQL error code: 2014 , SQLState: HY000 and Commands out of sync error why ?
Posted by: Meir Meir
Date: July 26, 2011 02:07AM

Hi im using Connector/C++ and executing simple 2 sql commands like this : the first select sql run ok but the second one cause this exception error :

ERR: Commands out of sync; you can't run this command now (MySQL error code: 2014, SQLState: HY000 )

here is the code :
//member of the class
ResultSet *temp_res;
// in different method
m_driver = get_driver_instance();
m_con = m_driver->connect(m_DBhost,m_User,m_Password);
m_con->setSchema(m_Database);

//here i excute the querys :
vector<string> query;
query.push_back("SELECT * FROM info_tbl");
query.push_back("INSERT INTO info_tbl (id,name,age)VALUES (0,foo,36)");
query.push_back("SELECT * FROM info_tbl");

ResultSet *res;
Statement *stmt;
bool stmtVal = false;

try{
stmt = m_con->createStatement();
for(size_t i = 0;i < querys.size();i++)
{
string query = querys.at(i);
stmtVal = stmt->execute(query);

if(!stmtVal)
{

string error_log ="sql statment:";
error_log.append(query);
error_log.append(" failed!");

cout << error_log << endl;
break;

}
}
if(stmtVal)
{
if(returnSet)
{
res = stmt->getResultSet();
temp_res = res;
}
}



delete stmt;
//close connection to db
m_con->close();
} catch (sql::SQLException &e) {
......
}


his is my simple table :

Column Type Null
id int(10) No
name varchar(255) No
age int(10) No

Options: ReplyQuote


Subject
Views
Written By
Posted
Connector/C++ MySQL error code: 2014 , SQLState: HY000 and Commands out of sync error why ?
4862
July 26, 2011 02:07AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.