问题描述
我正在为一款不太受欢迎的mmorpg游戏编写服务器mu软件,并且我正在使用mysql Connector for c ++与我的数据库进行连接。重新安装Windows(和整个开发环境)后,我得到了一个奇怪的mysql连接器异常。
I am writing a server-emu software for a not-so-popular mmorpg game, and I'm using mysql connector for c++ to connect with my database. After I reinstalled Windows (and my whole dev environment) I've got a weird mysql connector exception.
我用于连接数据库的代码如下:
The code I use to connect with the database looks like this:
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)
(all variables like user, password etc. are std::strings)
这以前曾经起作用,但现在它在控制台中打印如下:
This was working before, but now it prints in the console this:
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);
一切正常。
我不知道没有任何想法如何解决此问题以及为什么会这样。
I don't have any ideas how to fix this and why is this happening. Please help.
推荐答案
是的,请使用v1.1.5。 1.16版本有错误。
yes,please use v1.1.5. the version of 1.16 has bug.
tar -xf mysql-connector-c++-1.1.5.tar.gz
cd mysql-connector-c++-1.1.5
cmake . -DMYSQL_CONFIG_EXECUTABLE=/usr/local/mysql/bin/mysql_config \
-DMYSQL_LIB=/usr/local/mysql/lib/libmysqlclient.so
make
sudo make install
这篇关于适用于C ++的MySQL连接器| setSchema上的MySQL_Connection :: setReadOnly()异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!