- 论坛徽章:
- 0
|
测试程序如下
try{
Connection * conn;
Statement * stmt;
char connstr[] = "dev;dev123";
Environment* env;
env = Environment::createEnvironment();
conn = env->createConnection("dev","dev123");
stmt = conn->createStatement();
stmt->setSQL("update mhb_test set id=6 where name=:1");
string str("dkk");
stmt->setString(1,str);
//stmt->setInt(1,6);
int res = stmt->executeUpdate();
conn->commit();
printf("update %d rows\n",res);
}catch (SQLException &sqlExcp)
{
DB_LOG_ERROR("[%s][%d]errcode=%d %s\n",__FILE__,__LINE__,sqlExcp.getErrorCode(),sqlExcp.getMessage().c_str());
return 1;
}
执行后打印 update 0 rows 数据库没变化 |
|