mardi 31 décembre 2019

16-bit integer in preparedstatement cppconn

I have column in MySQL table which is of type Smallint. I want to insert a row in the table in C++ using cppconn. I am using PreparedStatement. I cannot find an api like setInt16 or setShort. It is throwing error with code 1264 if I use setInt with 16-bit integer. Is there any way of doing it?

Column A -> Int auto_increment
Column B -> SmallInt


sql::PreparedStatement *insert_stmt = m_con->prepareStatement("INSERT INTO MyTable VALUES (?)");
int16_t x = 10;
insert_stmt->setInt(1, x);
insert_stmt->execute();

It is showing the following error :-

Out of range value for column 'B' at row 1 (MySQL error code: 1264, SQLState: 22003 )

Aucun commentaire:

Enregistrer un commentaire