Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cppconn/datatype.h>
- #include <cppconn/config.h>
- #include <cppconn/resultset.h>
- #include <cppconn/statement.h>
- #include <mysql_connection.h>
- #include <mysql_driver.h>
- #include <mysql_error.h>
- using namespace std;
- using namespace sql;
- int main(void) {
- sql::mysql::MySQL_Driver *driver;
- sql::Statement *stmt;
- sql::ResultSet *res;
- sql::Connection *con;
- string breakpoint;
- driver = sql::mysql::get_mysql_driver_instance();
- con = driver->connect("tcp://127.0.0.1:4406", "", "");
- stmt = con->createStatement();
- res = stmt->executeQuery("SELECT Name, Population FROM world.city limit 10");
- while (res->next()) {
- cout << "Name = '" << res->getString("Name") << "'" << " Pop = " << res->getInt("Population")<< endl;
- }
- cin >> breakpoint;
- delete res;
- delete stmt;
- delete con;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement