我尝试使用setBlob(),如下所示:
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()崩溃了。我做错了什么?
答案 0 :(得分:1)
你确定它没有崩溃:
s->setBlob(1, &stream);
检查调试器以确保s不是NULL或废话值。