Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to check session created or not in MySQL X DevApi A,k,a X Protocol.

How to check session created or not in MySQL X DevApi A,k,a X Protocol.

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++mysqlvisual-studiosysadmin
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lynxpravoka
    wrote on last edited by
    #1

    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;
    }

    J 1 Reply Last reply
    0
    • L lynxpravoka

      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;
      }

      J Offline
      J Offline
      Jochen Arndt
      wrote on last edited by
      #2

      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;
      }

      L 1 Reply Last reply
      0
      • J Jochen Arndt

        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;
        }

        L Offline
        L Offline
        lynxpravoka
        wrote on last edited by
        #3

        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.

        J 1 Reply Last reply
        0
        • L lynxpravoka

          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.

          J Offline
          J Offline
          Jochen Arndt
          wrote on last edited by
          #4

          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).

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups