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
|
MYSQL * Conn::connection()
{
//MY_INIT(argv[0]);
mysql_init(mysql);
if(mysql_library_init(0,NULL, NULL))
{
std::cout << "mysql lib init " << std::endl;
exit(1);
}
else
{
std::cout << "library initialized\t";
}
// mysql = mysql_init(NULL);
// mysql = mysql_init(nullptr);
mysql = mysql_init(mysql);
if(mysql == NULL)
{
std::cout<< "mysql connector is NULL";
//cin.get();
exit(2);
}
else
{
std::cout << "mysql_init initialised\t";
}
// conn = mysql_real_connect (&mysql,"serverora.db.net","rahul","rahul","cbs",3306,NULL,0);
mysql = mysql_real_connect (mysql,opt_host,opt_user_name,opt_password,opt_db_name,opt_port,opt_socket_name,opt_flags);
if(mysql == 0)
{
std::cout << "mysql_real_connect returned 0 : ";
return 0;
}
else
{
std::cout << "mysql initialized";
}
return mysql;
}
|