使用MySQL Connector C++的PreparedStatement更新数据碰到类型异常

使用MySQL Connector C++ 的preparedStatement,在更新数据时,碰到异常

  1.  pstmt = con->prepareStatement("INSERT INTO logs(day, time, uid, vid, cid, cv, did, res) VALUES (?,?, ?,?, ?,?, ?,?)");
  2.  pstmt->setInt(1, day);
  3.  pstmt->setInt(2, time);
  4.             //…..
  5.         pstmt->setInt(8, res);
  6.  
  7.  pstmt->executeUpdate();

执行executeUpdate时碰到异常: Using unsupported buffer type: 0 (parameter: 1)

不知道怎么回事,使用google搜索了一会,没有找到解决方法。
没有办法,将相关代码替换使用Statement的execute方法处理,执行ok

Popularity: 7% [?]

Related

Comments

2 Responses to “使用MySQL Connector C++的PreparedStatement更新数据碰到类型异常”

  1. lxmuyu on January 28th, 2011 11:13 am

    大仙~我也这问题~我是跑的例子,竟然通过不了。。。
    ubuntu + mysql + connector/c++

    pstmt = con->prepareStatement(“INSERT INTO test(id) VALUES (?)”);
    for (int i = 1; i setInt(1, i);
    pstmt->executeUpdate();
    }
    delete pstmt;

    请问,现在您有解了么?

    [Reply]

  2. gefu on May 16th, 2011 1:44 pm

    这个问题也折磨我了很久,版本的问题,换个最新的mysql connector估计就行了,我用mysql 5.1.39 + mysql connector 1.0.5不行,用mysql 5.0.18 + mysql connector 1.0.5就没问题

    [Reply]