Advertisement
Guest User

Untitled

a guest
May 1st, 2023
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <iostream>
  3.  
  4. #include "mysql_connection.h"
  5. #include <cppconn/driver.h>
  6. #include <cppconn/exception.h>
  7. #include <cppconn/prepared_statement.h>
  8.  
  9.  
  10. int main()
  11. {
  12.  
  13. const std::string server = "xxxxxx";
  14. const std::string username = "xxxxx";
  15. const std::string password = "xxxxx";
  16.  
  17.  
  18. sql::Driver* driver;
  19. sql::Connection* connection;
  20. sql::Statement* statement;
  21. sql::ResultSet* resultSet;
  22.  
  23. // Test connections
  24. try
  25. {
  26. driver = get_driver_instance();
  27. connection = driver->connect(server, username, password);
  28. std::cout << "connection was successful";
  29. }
  30. catch (sql::SQLException e)
  31. {
  32. std::cout << "Could not connect to server. Error message: " << e.what() << std::endl;
  33. system("pause");
  34. exit(1);
  35. }
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement