MySQL Forums
Forum List  »  Connector/C++

C++ MySQL Connector 1.1.0 Throws exception but query succeeds
Posted by: James Barajas
Date: July 31, 2012 09:34AM

The C++ MySQL Connector is throwing exceptions every time I try to insert a record into one of my MySQL tables.
The error code is (MySQL error code: 0, SQLState: 00000)
but the query is successful.
I also tried executing the exact same query directly on MySQL I get no error.
so why is the connector throwing an exception if there is no error??
how can I get around this?

here is my code:

void DBMgr::addRecord(string id, int num, string tblName)
{

SQLString query;
Statement *stmt;
stmt = m_mySqlConnection -> createStatement();

query = "INSERT INTO ";
query.append(tblName);
query.append(" SET id= '");
query.append(id);
query.append("', num = '");
query.append(boost::lexical_cast<std::string>(num));
query.append("';");
cout << "executing query "<< query << endl;
try {

stmt->executeQuery(query);
stmt->close();
delete stmt;
}
catch (SQLException &e) {
cout << "ERROR: SQLException in " << __FILE__;
cout << " (" << __func__<< ") on line " << __LINE__ << endl;
cout << "ERROR: " << e.what();
cout << " (MySQL error code: " << e.getErrorCode();
cout << ", SQLState: " << e.getSQLState() << ")" << endl;
}
}

any help is appreciated.

Options: ReplyQuote


Subject
Views
Written By
Posted
C++ MySQL Connector 1.1.0 Throws exception but query succeeds
8090
July 31, 2012 09:34AM


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.