问题
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