Hi:
It always throw mysqlpp::Exception:"Error: Failed to find MySQL C
API type ID for int",so I've try to pass a sql_int value to query,but got
a same result;
The system is "AIX p570a 3 5 00C4E37B4C00", Compiler xlC_r.
By the way, if reply,please reply to huruware@stripped too.
The code is bellow:
try{
mysqlpp::Connection conn(false);
if (conn.connect("dbctest","localhost", "root", "root111"
))
{
printf("connect to db success\n");
mysqlpp::Query query = conn.query("select * from
test where id = %0q and name = %1q");
query.parse();
mysqlpp::SQLQueryParms sqp;
sqp.resize(2);
mysqlpp::sql_int sqlint = 5
sqp[0] = sqlint; // throw mysqlpp::Exception here
sqp[1] = mysqlpp::SQLTypeAdapter(string("test5"));
mysqlpp::UseQueryResult res = query.use(sqp);
if (mysqlpp::Row row = res.fetch_row())
{
cout << '\t' << row["name"] << endl;
}
else
{
cerr << "Failed to get item list: " <<
query.error() << endl;
return 1;
}
return 0;
}
else {
cerr << "DB connection failed: " << conn.error()
<< endl;
return 1;
}
}
catch (const mysqlpp::BadQuery& er) {
// Handle any query errors
cerr << "Query error: " << er.what() << endl;
return -1;
}
catch (const mysqlpp::BadConversion& er) {
// Handle bad conversions
cerr << "Conversion error: " << er.what() << endl
<<
"\tretrieved data size: " << er.retrieved
<<
", actual size: " << er.actual_size <<
endl;
return -1;
}
catch (const mysqlpp::Exception& er) {
// Catch-all for any other MySQL++ exceptions
cerr << "Error: " << er.what() << endl;
return -1;
}
Thanks, and best wish!
--------------------------------------------------------
ZTE Information Security Notice: The information contained in this mail is solely property
of the sender's organization. This mail communication is confidential. Recipients named
above are obligated to maintain secrecy and are not permitted to disclose the contents of
this communication to others.
This email and any files transmitted with it are confidential and intended solely for the
use of the individual or entity to whom they are addressed. If you have received this
email in error please notify the originator of the message. Any views expressed in this
message are those of the individual sender.
This message has been scanned for viruses and Spam by ZTE Anti-Spam system.