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

Lost connection to MySQL server during query (no replies)

$
0
0
Hi all,
Recently I trying to using connector cpp 1.1.7 to access mysql server(both os is Debian stretch),but encounter "Lost connection to MySQL server during query" problem.It happens when i using transaction, my transaction code looks like :
bool ExecTransaction(const std::vector<std::string>& sqls) {
sql::Statement* statement = nullptr;
sql::Connection* conn = nullptr;
conn = GetConnection();
// for simple, delete code is not written here

try {
conn->setSchema(schema);
statement = conn->createStatement();
conn->setAutoCommit(false);
for (auto& sql : sqls) {
statement->execute(sql);
}
conn->commit();
return true;
} catch (sql::SQLException& e) {
goto rollback;
} catch (std::runtime_error& e) {
goto rollback;
}

rollback:
try {
conn->rollback();
return false;
} catch (sql::SQLException& e) {
return false;
} catch (std::runtime_error& e) {
return false;
}
}

Is there any problem here?Why this problem won't happen if i don't use transaction.

Viewing all articles
Browse latest Browse all 527

Trending Articles



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