Advertisement
Guest User

Untitled

a guest
Jun 12th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <windows.h>
  2. #include <iostream>
  3. #include <mysql/mysql.h>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. char *host = "localhost";
  10. char *user = "root";
  11. char *pass = "pass";
  12. char *db = "database";
  13.  
  14. MYSQL *sock;
  15. sock = mysql_init(0);
  16. if (sock) cout << "Wena Sock Handle!" << endl;
  17. else {
  18. cout << "Pal Pico la Sock Handle!" << mysql_error(sock) << endl;
  19. }
  20.  
  21. if (mysql_real_connect(sock,host,user,pass,db,3306,"mysql",0))
  22. cout << "connection Wena!" << endl;
  23. else {
  24. cout << "Connection Pal Pico!: " << mysql_error(sock) << endl;
  25. }
  26. cout << "connection character set: " << mysql_character_set_name(sock) << endl;
  27. system("PAUSE");
  28.  
  29. mysql_close(sock);
  30.  
  31. return EXIT_SUCCESS;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement