Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <mysql/mysql.h>
- #include <stdio.h>
- const char *sock = "/tmp/akonadi-babydragon.9F3Ue5/mysql.socket";
- void connectOnce() {
- if(mysql_library_init(0, 0, 0)) {
- printf("lib init fail\n");
- }
- MYSQL *mysql = mysql_init(NULL);
- if(mysql_real_connect(mysql, NULL, NULL, NULL, NULL, 0, sock, 0) == NULL) {
- printf("connect fail: %s\n", mysql_error(mysql));
- }
- mysql_close(mysql);
- mysql_library_end();
- }
- int main() {
- printf("first connect\n");
- connectOnce();
- printf("second connect\n");
- connectOnce();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement