unsigned long __stdcall update(void *argc)
{
int i = 0;
for(;;)
{
Sleep(1000 * 0.1);
std::string sql = "update processingtransactioninterface";
sql += " set actresult = 1 where actresult = 2"; //CMysqlClient client;
//mysqlpp::Connection * conn = client.GetConnect(1);
//if(conn == NULL)
//{
// continue;
//}
mysqlpp::Connection conn(false); // = new mysqlpp::Connection(false);
conn.connect("new_db","127.0.0.1","root","mysql5",3306);
mysqlpp::Query query = conn.query();
//其实就是下面这句不执行,都会有严重得内存泄漏
if(!query.exec(sql))
{
std::cout<<"update fail"<<endl;
}
else
{
std::cout<<"update success"<<endl;
}
}
return 0;
}int main( int argc, char * argv[] )
{
unsigned long p3 = 1;
int parm3 = 2;
::CreateThread(0,0,update,(void*)&parm3,0,&p3); system("pause");
return 1;
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货