char * password /* = "chenmin" */, char * database /* = "HostCache" */){ CDBParameter * lpDBParam = new CDBParameter(); lpDBParam->host = host; lpDBParam->user = user; lpDBParam->password = password; lpDBParam->database = database; lpDBParam->port = 0; lpDBParam->unix_socket = NULL; lpDBParam->client_flag = 0; try { //连接 for(int index = 0; index < CONNECTION_NUM; index++) { MYSQL * pConnectHandle = mysql_init((MYSQL*) 0); //初始化连接句柄 if(!mysql_real_connect(pConnectHandle, lpDBParam->host, lpDBParam->user, lpDBParam->password, lpDBParam->database,lpDBParam->port,lpDBParam->unix_socket,lpDBParam->client_fla)) return false;//加入到空闲队列中 m_lsIdleList.push_back(pConnectHandle); } } catch(...) { return false; } return true;} //提取一个空闲句柄供使用MYSQL * CDBManager::GetIdleConnectHandle(){ MYSQL * pConnectHandle = NULL; m_ListMutex.acquire(); if(m_lsIdleList.size()) { pConnectHandle = m_lsIdleList.front(); m_lsIdleList.pop_front(); m_lsBusyList.push_back(pConnectHandle); } else //特殊情况,闲队列中为空,返回为空 { pConnectHandle = 0; } m_ListMutex.release(); return pConnectHandle;} //从使用队列中释放一个使用完毕的句柄,插入到空闲队列void CDBManager::SetIdleConnectHandle(MYSQL * connecthandle){ m_ListMutex.acquire(); m_lsBusyList.remove(connecthandle); m