//through the product info get the best channel to create order //@return the channel num int ChargeBusiness::SelectBestChannel(int value, int province, int op, vector<ChannelInfo>& channels){ int ret = 0; Statement *stmt = NULL; try{ stmt = conn->createStatement(SQL_SELECT_CHANNEL); stmt->setInt(1, value); //product value stmt->setInt(2, province); //provice of product stmt->setInt(3, op); //operator of product ResultSet *rs = stmt->executeQuery(); while(rs->next()) { ChannelInfo channel; channel.channelId = rs->getInt(1); //channel id //channel.channelName = rs->getString(2); //channel name channel.sname = rs->getString(2); //short name channel.priority = rs->getInt(3); //priority channel.repeat = rs->getInt(4); //repeat times channel.discount = rs->getFloat(5); //discount of product channel.interfaceName = rs->getString(6); //the interface of channel,through it to find the class to handle order channel.pid = rs->getString(7); //the product id given by channel channel.private_key = rs->getString(8); //the private key given by channel channel.query_interval = rs->getInt(9); //query order interval channels.push_back(channel); ret++; } stmt->closeResultSet(rs); }catch(std::exception &e){ HandleException(e); ret = -1; } Finish(); if(stmt) conn->terminateStatement(stmt); return ret; }