开发者

How to save an array of unsigned char to MySQL

Any idea on how to save an array of unsigned char to a field in MySQL database开发者_如何学JAVA ? I'm considering BLOB, but how can I convert it to QByteArray and convert it back to an array of unsigned char when I want to ? BTW, I'm trying to save fingerprint data.


I managed to solve this using the codes below (copied directly from my project)


struct fp {
    unsigned char Template[MAX_TEMPLATE_SIZE];
    int size;
};


// unsigned char to QByteArray
QByteArray FingerPrint::charArrayToByteArray(fp fp0) {

    QByteArray ba;
    for (int i=0; i

// QByteArray to unsigned char fp FingerPrint::byteToFp(QByteArray *ba) { fp fp0; for (int i=0; isize(); i++) { fp0.Template[i] = ba->at(i); } fp0.size = ba->size(); return fp0; }

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜