【发布时间】:2012-02-02 14:16:43
【问题描述】:
我正在使用 MySQL C++ 连接器版本 1.1.0。 这就是我的代码的样子:
PreparedStatement *pStatement;
connection->setAutoCommit(false);
pStatement = connection->prepareStatement("UPDATE records "
"SET is_processed = ? "
"WHERE id = ?");
//LOOP BEGIN
pStatement->setInt(1, is_processed);
pStatement->setString(2, record_id);
pStatement->execute();
//LOOP END
int updated_records;
try
{
updated_records = pStatement->getUpdateCount();
}
catch(SQLException&e)
{
cout << "ERROR: " << e.what();
cout << " (MySQL error code: " << e.getErrorCode();
cout << ", SQLState: " << e.getSQLState() << ")" << endl;
}
connection->commit();
connection->setAutoCommit(true);
抛出异常,输出如下:
ERROR: MySQL_Prepared_Statement::getUpdateCount (MySQL error code: 0, SQLState: )
所以它什么也没说。 getUpdateCount() 函数有什么问题?有什么方法可以获得更详细的错误报告级别?
编辑
还有其他方法可以使用 mysql c++ 连接器获取更新的行数吗?
【问题讨论】:
标签: c++ mysql-connector