Quantcast
Channel: MySQL Forums - Connector/C++
Viewing all articles
Browse latest Browse all 527

C++ MySQL Connector 1.1.0 Throws exception but query succeeds (no replies)

$
0
0
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.

Viewing all articles
Browse latest Browse all 527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>