c++ - 用于 C++ 的 MySQL 连接器 | setSchema 上的 MySQL_Connection::setReadOnly() 异常

标签 c++ mysql exception schema connector

我正在为一个不太流行的 mmorpg 游戏编写一个 server-emu 软件,我正在使用 mysql connector for c++ 连接我的数据库。在我重新安装 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,它不再引发此错误。

关于c++ - 用于 C++ 的 MySQL 连接器 | setSchema 上的 MySQL_Connection::setReadOnly() 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28462633/

相关文章:

mysql - tecdoc 查询需要超过 5 分钟

java - 将 RuntimeException 转换为 Checked 是一个好习惯吗?

c++ - 使用 Python 的 3d 游戏,从无到有

mysql - 如何在限制一个 SQL 查询中不同 id 的数量的同时获取不同数量的行?

c++ - glUnmapBuffer 同时保持 glMapBuffer 内存有效为只读

php - 用于删除数据库中选定行的表单 : displays confirmation always

ios - 什么可能导致 Swift sharedInstance 返回上的 EXC_BREAKPOINT

java - Java7 的多异常 catch 子句是否使用鸭子类型?

c++ - 如何正确删除多维 vector ?

c++ - 是否可以声明属于模板类的单个实例化的函数?