ERLEDIGT
NEIN
NEIN
ANTWORTEN
1
1
ZUGRIFFE
3294
3294
EMPFEHLEN
-
Moin,
wie im Betreff gesagt connecte ich zu meinem MySQL Server(localhost).
Für die MySQL connection habe ich mir eine ganz kleine Klasse geschrieben.
Wenn die connection beendet wird und wieder aufgebaut werden soll funktioniert es
nicht mehr. Wäre nett wenn mir jemand helfen könnte den Fehler zu finden ich sehe da überhaupt nichts falsches.
Hier etwas code:
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
//// mysqlConnection.h //// #ifndef MYSQLCONNECTION_H #define MYSQLCONNECTION_H #include <iostream> #include <windows.h> #include <MySQL\mysql.h> class mysqlConnection { private: MYSQL conn; std::string info[4]; public: void setInfo(std::string host,std::string user,std::string password, std::string database); bool connect(); bool query(std::string data); MYSQL_RES *lastRes(); void resFree(MYSQL_RES *data); void close(); }; #endif //// mysqlConnection.cpp //// #include "mysqlConnection.h" void mysqlConnection::setInfo(std::string host,std::string user,std::string password,std::string database) { info[0] = host; info[1] = user; info[2] = password; info[3] = database; } bool mysqlConnection::connect() { mysql_init(&conn); if(mysql_real_connect(&conn,info[0].c_str(),info[1].c_str(),info[2].c_str(),info[3].c_str(),3306,NULL,0)) return true; else return false; } bool mysqlConnection::query(std::string data) { if(!mysql_query(&conn,data.c_str())) return false; else return true; } MYSQL_RES *mysqlConnection::lastRes() { return mysql_store_result(&conn); } void mysqlConnection::resFree(MYSQL_RES *data) { mysql_free_result(data); } void mysqlConnection::close() { mysql_close(&conn); }Don't blame people for bugs. Work together to make things better. No
finger pointing! Not ever! A good rule is to Never Assume An Attack.
If you find yourself getting angry, assume it's a misunderstanding, not an
attack.
-
Du solltest vielleicht mal zeigen wie Du Deine Klasse benutzt und wie Du den Reconnect machst.
X-ITEC IT-Consulting
X-ITEC CMS * Win / Linux Programmierung * 2D / 3D Coding * C/C++ * PHP * Assembler * Security-Research
Ähnliche Themen
-
MySQL Connection
Von crsakawolf im Forum ASPAntworten: 4Letzter Beitrag: 05.01.10, 08:19 -
Problem mit MySQL extern Connection s4y
Von Moba im Forum Relationale DatenbanksystemeAntworten: 1Letzter Beitrag: 27.02.07, 00:01 -
Mysql connection
Von cavigelli im Forum Relationale DatenbanksystemeAntworten: 2Letzter Beitrag: 05.07.06, 16:53 -
mysql connection mit c++
Von the_smooth im Forum C/C++Antworten: 4Letzter Beitrag: 30.11.04, 18:17 -
mySQL connection
Von dji im Forum ASPAntworten: 5Letzter Beitrag: 30.08.02, 10:17





Zitieren
Login






