/// <summary> /// Create an instance of the database client. /// </summary> /// <param name="serverIp">The IP address or hostname of the database server.</param> /// <param name="serverPort">The TCP port of the database server.</param> /// <param name="username">The username to use when authenticating with the database server.</param> /// <param name="password">The password to use when authenticating with the database server.</param> /// <param name="database">The name of the database with which to connect.</param> public DatabaseClient( string serverIp, int serverPort, string username, string password, string database) { if (String.IsNullOrEmpty(serverIp)) { throw new ArgumentNullException(nameof(serverIp)); } if (serverPort < 0) { throw new ArgumentOutOfRangeException(nameof(serverPort)); } if (String.IsNullOrEmpty(database)) { throw new ArgumentNullException(nameof(database)); } _Settings = new DatabaseSettings(DbTypes.Mysql, serverIp, serverPort, username, password, database); _ConnectionString = MysqlHelper.ConnectionString(_Settings); SetMaxStatementLength(); }
/// <summary> /// Create an instance of the database client. /// </summary> /// <param name="serverIp">The IP address or hostname of the database server.</param> /// <param name="serverPort">The TCP port of the database server.</param> /// <param name="username">The username to use when authenticating with the database server.</param> /// <param name="password">The password to use when authenticating with the database server.</param> /// <param name="database">The name of the database with which to connect.</param> public DatabaseClient( string serverIp, int serverPort, string username, string password, string database) { if (String.IsNullOrEmpty(serverIp)) { throw new ArgumentNullException(nameof(serverIp)); } if (serverPort < 0) { throw new ArgumentOutOfRangeException(nameof(serverPort)); } if (String.IsNullOrEmpty(database)) { throw new ArgumentNullException(nameof(database)); } _ServerIp = serverIp; _ServerPort = serverPort; _Username = username; _Password = password; _DatabaseName = database; _ConnectionString = MysqlHelper.ConnectionString(_ServerIp, _ServerPort, _Username, _Password, _DatabaseName); }
/// <summary> /// Create an instance of the database client. /// </summary> /// <param name="settings">Database settings.</param> public DatabaseClient(DatabaseSettings settings) { _Settings = settings ?? throw new ArgumentNullException(nameof(settings)); if (_Settings.Type != DbTypes.Mysql) { throw new ArgumentException("Database settings must be of type 'Mysql'."); } _ConnectionString = MysqlHelper.ConnectionString(_Settings); }