MySQL Forums
Forum List  »  Connector/C++

Re: Connector/C++ v 8 and binding parameters
Posted by: Walter Oney
Date: January 27, 2020 01:05AM

Problem solved: the key lies in keeping the istream that sources the blob around until AFTER executing the update statement. In sketch, suppose you have an unsigned character array "blobdata" of length "bloblen":

sql::Driver* driver = get_driver_instance();
sql::Connection* con = driver->connect("tcp://localhost:3306", <user>, <pw>);
sql::PreparedStatement* stmt = con->prepareStatement(<query string>);

std::stringstream* s = new stringstream(string((const char*) blobdata, bloblen), ios::in);
stmt->setBlob(<1-based field # in prepared stmt>, s);

delete s;

Options: ReplyQuote

Written By
Re: Connector/C++ v 8 and binding parameters
January 27, 2020 01:05AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.