Created
September 8, 2015 17:26
-
-
Save larryzhao/9dc2db15621d76939f37 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MySQLTest.cpp : Defines the entry point for the console application. | |
// | |
#include "stdafx.h" | |
#include <iostream> | |
#include "mysql_connection.h" | |
#include "mysql_driver.h" | |
#include "cppconn\statement.h" | |
#include "cppconn\resultset.h" | |
using namespace sql; | |
using namespace std; | |
int main() | |
{ | |
mysql::MySQL_Driver *driver; | |
Connection *conn; | |
Statement *stmt; | |
ResultSet *result; | |
driver = sql::mysql::get_mysql_driver_instance(); | |
conn = driver->connect("tcp://127.0.0.1:3306", "root", "admin"); | |
conn->setSchema("sakila"); | |
stmt = conn->createStatement(); | |
result = stmt->executeQuery("SELECT 'Hello World!' AS _message"); | |
result->next(); | |
string message = result->getString("_message"); | |
delete result; | |
delete stmt; | |
delete conn; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment