我正在为一款不太流行的 MMORPG 游戏编写服务器 EMU 软件,并且我正在使用 C++ 的 mysql 连接器来连接我的数据库。在我重新安装 Windows(以及我的整个开发环境)后,我遇到了一个奇怪的 mysql 连接器异常。
我用来连接数据库的代码如下所示:
try
{
this->driver = get_driver_instance();
std::cout << "SQL Driver Name: " << this->driver->getName() << std::endl;
std::cout << "Connecting as " << user << "@" << host << " using password " << password << std::endl;
this->connection = this->driver->connect(host, user, password);
std::cout << "Setting schema to " << schema << std::endl;
this->connection->setSchema(schema);
} catch(sql::SQLException &e)
{
std::cout << "# ERR: SQLException in " << __FILE__;
std::cout << "(" << __FUNCTION__ << ") on line " << __LINE__ << std::endl;
std::cout << "# ERR: " << e.what();
std::cout << " (MySQL error code: " << e.getErrorCode();
std::cout << ", SQLState: " << e.getSQLState() << " )" << std::endl;
return 1;
}
(所有变量如用户、密码等都是 std::strings)
这之前是有效的,但现在它在控制台中打印:
SQL Driver Name: MySQL Connector C++ (libmysql)
Connecting as root@tcp://localhost:3306 using password testpassword
Setting schema to testschema
ERR: SQLException in c:\whatever\db.cpp on line 22
ERR: MySQL_Connection::setReadOnly() (MySQL error code: 0, SQLState: )
没有这一行:
this->connection->setSchema(schema);
一切正常。
我不知道如何解决这个问题以及为什么会发生这种情况。请帮忙。
我有一个类似的问题,尽管在 Debian Wheezy 上,版本1.1.0-4+b1:
使用示例:
sql::Connection *con;
con->setSchema(mysql_schema);
哪个抛出:
MySQL_Connection::setReadOnly()
通过将 Connector/C++ 1.1.0-4+b1 替换为 1.1.5,它不再抛出此错误。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)