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
| #include <windows.h>
#include <iostream>
#include <mysql/mysql.h>
using namespace std;
int main()
{
//connection params
char *host = "http://sql.free.fr";
char *user = ""
char *pass = "";
char *db = "";
//sock
MYSQL *sock;
sock = mysql_init(0);
if (sock) cout << "sock handle ok!" << endl;
else {
cout << "sock handle failed!" << mysql_error(sock) << endl;
}
//connection
if (mysql_real_connect(sock, host, user, pass, db, 0, NULL, 0))
cout << "connection ok!" << endl;
else {
cout << "connection fail: " << mysql_error(sock) << endl;
}
//connection character set
cout << "connection character set: " << mysql_character_set_name(sock) << endl;
//wait for posibility to check system/mysql sockets
system("PAUSE");
//closing connection
mysql_close(sock);
return EXIT_SUCCESS;
} |
Partager