Set binary data using setblob in mysql connector/c++ causes crash

自作多情 提交于 2019-12-24 07:07:07

问题


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

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


回答1:


Are you sure that it isn't crashing on:

s->setBlob(1, &stream);

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



来源:https://stackoverflow.com/questions/1121142/set-binary-data-using-setblob-in-mysql-connector-c-causes-crash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!