How can I stop the function if MySQL could'nt connect to database?
Code:_mySqlConnection = _mySql.OpenDb("ip", 3306, "etc", "etc", "ip", this); // Lets say mysql host is down, how can I stop the function from going to code?//CODE
Stop function on MySQL connection error
Discussion in 'Rust Development' started by Reynostrum, Jul 12, 2016.
-
have you tried, try/catch?
This could allow you to keep trying to connect on failure as wellCode:try { _mySqlConnection = _mySql.OpenDb("ip", 3306, "etc", "etc", "ip", this); } catch (Exception e) { Puts(e); } -
The MySQL extension catches exceptions currently.
_mySqlConnection might be null as a result of that, and in either case, once you run a query against the DB, the result set will be null as well if it can't query the DB.
Otherwise, @Calytic might be able to provide more insight
