日期:2014-05-16 浏览次数:20681 次
MySQL使用connector C/C+读取二进制字段,两种方法:
用getString
vector<char> vec; while (pResultSet->next()) { string str = pResultSet->getString("data"); vec.insert(vec.end(), str.begin(), str.end()); }
vector<char> vecALL; while (pResultSet->next()) { istream *pis= pResultSet->getBlob("data"); pis->seekg(0, ios::end); int sz = pis->tellg(); pis->seekg(ios::beg); vector<char> vecTemp; vecTemp.resize(sz); pis->read(&vecTemp[0], sz); vecALL.insert(vecALL.end(), vecTemp.begin(),vecTemp.end()); }