How to check session created or not in MySQL X DevApi A,k,a X Protocol.
-
it's been 2 days. i'm struggle with this things. this's still new. the documented it just only help a bit. i want to check session created or not. a.k.a Connected or not. i don't know why the developer MySQL make new terms to call a thing. in this code. everytime i change something credential thing like host, port, user,pass. it return same. and return unexpected result with long zero 00000000000000 if use cout to sess. in my server i already enable X Plugin. my enviroment is Visual Studio Community 2017 c++ desktop.
#include
#include "mysql_xapi.h"using namespace std;
int main()
{
// initiliziation
mysqlx_session_t * sess;
char conn_error[MYSQLX_MAX_ERROR_LEN];
int err_code;
// open session. i use port 3306 cause this my mysql default port run. but in documented it says default port is 33060. i don't know it's seperate port to access. but when i change it to 33060. the result still same.sess = mysqlx\_get\_session("127.0.0.1", 3306, "root", "root", "test", conn\_error, &err\_code); if(!sess)
{
cout << "It's not connect";
}
else
{
cout << "It's connect";
}// close session
mysqlx_session_close(sess);
return 0;
} -
it's been 2 days. i'm struggle with this things. this's still new. the documented it just only help a bit. i want to check session created or not. a.k.a Connected or not. i don't know why the developer MySQL make new terms to call a thing. in this code. everytime i change something credential thing like host, port, user,pass. it return same. and return unexpected result with long zero 00000000000000 if use cout to sess. in my server i already enable X Plugin. my enviroment is Visual Studio Community 2017 c++ desktop.
#include
#include "mysql_xapi.h"using namespace std;
int main()
{
// initiliziation
mysqlx_session_t * sess;
char conn_error[MYSQLX_MAX_ERROR_LEN];
int err_code;
// open session. i use port 3306 cause this my mysql default port run. but in documented it says default port is 33060. i don't know it's seperate port to access. but when i change it to 33060. the result still same.sess = mysqlx\_get\_session("127.0.0.1", 3306, "root", "root", "test", conn\_error, &err\_code); if(!sess)
{
cout << "It's not connect";
}
else
{
cout << "It's connect";
}// close session
mysqlx_session_close(sess);
return 0;
}The function provides an error code and an error message upon failure. So print those out to get information on what went wrong:
sess = mysqlx_get_session("127.0.0.1", 3306, "root", "root", "test", conn_error, &err_code);
if (NULL == sess)
{
cout << "Connection failed; error " << err_code << ": " << conn_error << endl;
} -
The function provides an error code and an error message upon failure. So print those out to get information on what went wrong:
sess = mysqlx_get_session("127.0.0.1", 3306, "root", "root", "test", conn_error, &err_code);
if (NULL == sess)
{
cout << "Connection failed; error " << err_code << ": " << conn_error << endl;
}The error nothing helping. it shows string unexpected result and integer 1. can u figure out when the error like that? i think can't.
-
The error nothing helping. it shows string unexpected result and integer 1. can u figure out when the error like that? i think can't.
I would expect a meaningful error message if one the parameters is wrong. That generic message might indicate that it is networking problem. Because you are using localhost (127.0.0.1) it is probably not due to blocking by a firewall. You should check the port number and ensure that it is the port on which your server is listening. Depending on the operating system, you might also us a command line utility to show listening ports (as root/adminstrator: Linux:
lsof -nPi
, Windows:netstat -ban
).