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

stmt->executeUpdate();
delete s;

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Connector/C++ v 8 and binding parameters
472
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.