X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/005739f70a1d33ff4babbb3e6152fc6063aa480b..8f46a826a07310dbd76e4b3a15f63ae055272542:/projects/stargazer/plugins/store/mysql/mysql_store.cpp diff --git a/projects/stargazer/plugins/store/mysql/mysql_store.cpp b/projects/stargazer/plugins/store/mysql/mysql_store.cpp index cef72671..48be4aa6 100644 --- a/projects/stargazer/plugins/store/mysql/mysql_store.cpp +++ b/projects/stargazer/plugins/store/mysql/mysql_store.cpp @@ -113,6 +113,7 @@ return msc.GetPlugin(); //----------------------------------------------------------------------------- MYSQL_STORE_SETTINGS::MYSQL_STORE_SETTINGS() : settings(NULL) + , dbPort(0) { } //----------------------------------------------------------------------------- @@ -149,6 +150,17 @@ if (ParseParam(s.moduleParams, "server", dbHost) < 0 && ParseParam(s.moduleParams, "dbhost", dbHost) < 0) return -1; +std::string dbPortAsString; +if (ParseParam(s.moduleParams, "port", dbPortAsString) == 0 || + ParseParam(s.moduleParams, "dbport", dbPortAsString) == 0) +{ + if (GetInt(dbPortAsString, &dbPort, 0) != 0) + { + errorStr = "Can't parse db port from string: \"" + dbPortAsString + "\"\n"; + return -1; + } +} + return 0; } //----------------------------------------------------------------------------- @@ -198,7 +210,7 @@ else MYSQL * sock; if (!(sock = mysql_real_connect(&mysql,storeSettings.GetDBHost().c_str(), storeSettings.GetDBUser().c_str(),storeSettings.GetDBPassword().c_str(), - 0,0,NULL,0))) + 0,storeSettings.GetDBPort(),NULL,0))) { errorStr = "Couldn't connect to mysql engine! With error:\n"; errorStr += mysql_error(&mysql); @@ -2139,7 +2151,7 @@ MYSQL * MYSQL_STORE::MysqlConnect() const { } if (!(sock = mysql_real_connect(sock,storeSettings.GetDBHost().c_str(), storeSettings.GetDBUser().c_str(),storeSettings.GetDBPassword().c_str(), - 0,0,NULL,0))) + 0,storeSettings.GetDBPort(),NULL,0))) { errorStr = "Couldn't connect to mysql engine! With error:\n"; errorStr += mysql_error(sock);