Advertisement
oviwartowar

Untitled

Dec 7th, 2018
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <windows.h>
  3. #include <iostream>
  4. #include <mysql/mysql.h>
  5.  
  6.  
  7. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  8. using namespace std;
  9. char *host = "localhost";
  10. char *user = "root";
  11. char *pass = "";
  12. char *db = "mysql";
  13. int port = 0;
  14. char *sck = NULL;
  15. int flags = 0;
  16. MYSQL *conn;
  17. MYSQL *connection;
  18.  
  19.  
  20. int main(int argc, char** argv) {
  21. string stats;
  22. conn = mysql_init(NULL);
  23. if(conn == NULL)
  24. {
  25. cout<<"Error!!\n";
  26. exit(1);
  27. }
  28. connection = mysql_real_connect(conn,host,user,pass,db,port,sck,flags);
  29. if(connection == NULL){
  30. stats = "Connection MYSQL None Exist";
  31. }
  32. else{
  33. stats = "MYSQL Connected";
  34. }
  35. cout<<"Status: "<<stats<<endl<<endl;
  36. system("pause");
  37. mysql_close(conn);
  38. return EXIT_SUCCESS;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement