Specify SQL server port

ryzomclassic-develop
kaetemi 4 years ago
parent 9d722bb70f
commit ce8acd4ca2
No known key found for this signature in database
GPG Key ID: 9873C4D40BB479BC

@ -821,7 +821,7 @@ NLMISC_CLASS_COMMAND_IMPL(CServerPatchManager, setLaunchVersion)
NLMISC_CLASS_COMMAND_IMPL(CServerPatchManager, updateAESdataBase)
{
// check for command syntax
if (args.size()!=4)
if (args.size() != 4 && args.size() != 5)
return false;
// extract our command arguments
@ -829,13 +829,18 @@ NLMISC_CLASS_COMMAND_IMPL(CServerPatchManager, updateAESdataBase)
CSString dbHost = args[1];
CSString dbLogin = args[2];
CSString dbPassword = args[3];
uint port;
if (args.size() < 5 || !NLMISC::fromString(args[4], port)) // parse port
{
port = 0; // or use default
}
// if the domain doesn't exist then bomb out
DROP_IF(_Domains.find(domainName)==_Domains.end(),"Domain not recognised: "+domainName, return true);
// prepare our sql database connection...
MSW::CConnection conn;
conn.connect(dbHost, dbLogin, dbPassword, "nel_tool");
conn.connect(dbHost, dbLogin, dbPassword, "nel_tool", port);
// get hold of of the domain description object
SDomainDescription domainDescription;

@ -82,7 +82,7 @@ namespace MSW
bool CConnection::connect(const TParsedCommandLine &dbInfo)
{
const TParsedCommandLine *dbHost= dbInfo.getParam("host");
const TParsedCommandLine *dbport= dbInfo.getParam("port");
const TParsedCommandLine *dbPort= dbInfo.getParam("port");
const TParsedCommandLine *dbUser= dbInfo.getParam("user");
const TParsedCommandLine *dbPassword= dbInfo.getParam("password");
const TParsedCommandLine *dbBase= dbInfo.getParam("base");
@ -98,18 +98,24 @@ namespace MSW
}
return false;
}
uint port;
if (!dbPort || !NLMISC::fromString(dbPort->ParamValue, port)) // parse port
{
port = 0; // or use default
}
// connect to the database
return connect(dbHost->ParamValue, dbUser->ParamValue, dbPassword->ParamValue, dbBase->ParamValue);
return connect(dbHost->ParamValue, dbUser->ParamValue, dbPassword->ParamValue, dbBase->ParamValue, port);
}
bool CConnection::connect(const std::string &hostName, const std::string &userName, const std::string &password, const std::string &defaultDatabase)
bool CConnection::connect(const std::string &hostName, const std::string &userName, const std::string &password, const std::string &defaultDatabase, uint port)
{
// store the connection info
_ConnHostName = hostName;
_ConnUserName = userName;
_ConnPassword = password;
_ConnDefaultDatabase = defaultDatabase;
_ConnPort = port;
nlassert(!_Connected);
@ -147,13 +153,13 @@ namespace MSW
_ConnUserName.c_str(),
_ConnPassword.c_str(),
_ConnDefaultDatabase.c_str(),
0,
_ConnPort,
NULL,
CLIENT_FOUND_ROWS);
if (res == NULL)
{
nlwarning("Error during connection to database '%s:%s@%s' :", _ConnUserName.c_str(), _ConnDefaultDatabase.c_str(), _ConnHostName.c_str());
nlwarning("Error during connection to database '%s:%s@%s:%d' :", _ConnUserName.c_str(), _ConnDefaultDatabase.c_str(), _ConnHostName.c_str(), _ConnPort);
nlwarning("Mysql_real_connect error :%s ", mysql_error(_MysqlContext));
// the connection failed !
mysql_close(_MysqlContext);

@ -62,6 +62,7 @@ namespace MSW
std::string _ConnUserName;
std::string _ConnPassword;
std::string _ConnDefaultDatabase;
uint _ConnPort;
/// The mysql connection context
@ -94,7 +95,7 @@ namespace MSW
void addOption(mysql_option option, const char *value);
void clearOption(mysql_option option);
bool connect(const std::string &hostName, const std::string &userName, const std::string &password, const std::string &defaultDatabase);
bool connect(const std::string &hostName, const std::string &userName, const std::string &password, const std::string &defaultDatabase, uint port);
bool connect(const NLNET::TParsedCommandLine &databaseInfo);
void closeConn();

Loading…
Cancel
Save