Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Standard C++ includes*/
- #include <stdlib.h>
- #include <iostream>
- #include <mysqlx/xdevapi.h>
- using ::std::cout;
- using ::std::endl;
- using namespace ::mysqlx;
- int main(int argc, const char* argv[])
- {
- try {
- const char* url = (argc > 1 ? argv[1] : "mysqlx://pct@127.0.0.1");
- cout << "Creating session on " << url << " ..." << endl;
- Session sess(url);
- {
- cout << "Connected!" << endl;
- // Create the Schema "testSchema"; This code creates a schema without issue
- cout << "Creating Schema..." << endl;
- sess.dropSchema("testSchema");
- Schema mySchema = sess.createSchema("testSchema");
- cout << "Schema Created!" << endl;
- // Create the Table "testTable"; This code runs like normal, but the schema doesn't show
- cout << "Creating Table..." << endl;
- SqlStatement sqlcomm = sess.sql("USE testSchema SHOW tables;");
- sqlcomm.execute();
- }
- }
- catch (const mysqlx::Error& err)
- {
- cout << "MYSQL ERROR: " << err << endl;
- return 1;
- }
- catch (std::exception& ex)
- {
- cout << "STD EXCEPTION: " << ex.what() << endl;
- return 1;
- }
- catch (const char* ex)
- {
- cout << "EXCEPTION: " << ex << endl;
- return 1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement