下面给出了我的连接代码,这与他们的示例中给出的基本相同。这段代码工作得比较早,但我最近将mysql c ++连接器库更新到了1.1.7,这个异常开始出现了
driver = get_driver_instance();
try {
conn = driver->connect(dbHost, dbUser, dbPass);
} catch ( ... ) {
throw std::invalid_argument("Failed to connect to database! (Check credentials)");
}
//prints out "Is autocommit - 1"
std::cout<<"Is autocommit - "<<conn->getAutoCommit()<<std::endl;
conn->setAutoCommit(false); // <- this throws the exception
if ( conn->getAutoCommit() ) throw "Failed to disable auto commit mode!";
conn->setSchema(dbName);
例外类型:N3sql24InvalidArgumentExceptionE
exception.what():The connection is in autoCommit mode