Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SqlConnPool::Init #104

Open
1900100209 opened this issue May 1, 2024 · 1 comment
Open

SqlConnPool::Init #104

1900100209 opened this issue May 1, 2024 · 1 comment

Comments

@1900100209
Copy link

void SqlConnPool::Init(const char* host, int port,const char* user,const char* pwd, const char* dbName,
            int connSize = 10) {
  assert(connSize > 0);

  //默认创建10个mysql连接
  for (int i = 0; i < connSize; i++) {
    MYSQL *sql = nullptr;
    sql = mysql_init(sql);

// 这里直接assert(sql)不就行了吗?
    if (!sql) {
      LOG_ERROR("MySql init error!");
      assert(sql);
    }
@1900100209
Copy link
Author

    sql = mysql_real_connect(sql, host,user, pwd,dbName, port, nullptr, 0);

//还有这里,sql都是空了,为什么还存到connQue中?
    if (!sql) {
      LOG_ERROR("MySql Connect error!");
    }
    connQue_.push(sql);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant