Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2014
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. DatabaseClient::DatabaseClient(
  2.     const char* hostname,
  3.     const char* username,
  4.     const char* password,
  5.     const uint16_t port
  6. )
  7. #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)
  8.     : DatabaseClient(hostname, username, password, nullptr, port)
  9. {
  10. }
  11. #else
  12.     : connection_(mysql_init(nullptr))
  13. {
  14.     if (nullptr == connection_) {
  15.         throw MySqlException("Unable to connect to MySQL");
  16.     }
  17.  
  18.     const MYSQL* const success = mysql_real_connect(
  19.         connection_,
  20.         hostname,
  21.         username,
  22.         password,
  23.         nullptr,
  24.         port,
  25.         nullptr,
  26.         0);
  27.     if (nullptr == success) {
  28.         MySqlException mse(connection_);
  29.         mysql_close(connection_);
  30.         throw mse;
  31.     }
  32. }
  33. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement