mysql setschema,适用于C ++的MySQL连接器| setSchema上的MySQL_Connection :: setReadOnly()异常...

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;

}

(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: )

Without this line:

this->connection->setSchema(schema);

everything works fine.

I don't have any ideas how to fix this and why is this happening. Please help.

解决方案

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值