在MySQL Connector/C ++中使用setblob设置二进制数据会导致崩溃 [英] Set binary data using setblob in mysql connector/c++ causes crash

查看:214
本文介绍了在MySQL Connector/C ++中使用setblob设置二进制数据会导致崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试如下使用setBlob():

I tried to use setBlob() as follows:


class DataBuf : public streambuf
{
public:
   DataBuf(char * d, size_t s) {
      setg(d, d, d + s);
   }
};


char b[20];
DataBuf buffer((char*)b, 20);
istream stream(&buffer);

PreparedStatement* s = con->PrepareStatement("insert into mytable (mybin) values (?)");
s->setBlob(1, &stream);
int rows = s->executeUpdate();

这在executeUpdate()时崩溃.我在做什么错了?

This crashes at executeUpdate(). What am I doing wrong?

推荐答案

您确定它没有崩溃:

s->setBlob(1, &stream);

检查调试器,确保s不是NULL或废话值.

Check the debugger to make sure that s isn't NULL, or a crap value.

这篇关于在MySQL Connector/C ++中使用setblob设置二进制数据会导致崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆