commit 23d935f1c1513d546005111e4281978395d00059 Author: abdul Date: Fri Feb 20 15:11:22 2026 +0000 Ajouter main.cpp diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..e071303 --- /dev/null +++ b/main.cpp @@ -0,0 +1,38 @@ +#include +#include +#include +#include +#include +#include +#include "User.h" + +using namespace std; +int main() { + try { + sql::mysql::MySQL_Driver *driver; + sql::Connection *con; + + driver = sql::mysql::get_mysql_driver_instance(); + // Connexion à XAMPP + con = driver->connect("tcp://127.0.0.1:3306", "root", ""); + con->setSchema("university_db"); + + std::cout << "SUCCESS: Connexion etablie avec XAMPP !" << std::endl; + + sql::Statement *stmt = con->createStatement(); + sql::ResultSet *res = stmt->executeQuery("SELECT username FROM users"); + + while (res->next()) { + std::cout << "Utilisateur trouve dans la base : " << res->getString("username") << std::endl; + } + + delete res; + delete stmt; + delete con; + + } catch (sql::SQLException &e) { + std::cout << "ERREUR SQL : " << e.what() << std::endl; + } + + return 0; +} \ No newline at end of file