C++ MySQL Connector 1.1.0 Throws exception but query succeeds
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.
Subject
Views
Written By
Posted
C++ MySQL Connector 1.1.0 Throws exception but query succeeds
8284
July 31, 2012 09:34AM
3023
August 02, 2012 09:00AM
2756
August 02, 2012 12:36PM
2749
August 02, 2012 12:56PM
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.