You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
895 B
36 lines
895 B
#include <stdlib.h>
|
|
#include <iostream>
|
|
#include <mysql_connection.h>
|
|
#include <driver.h>
|
|
#include <exception.h>
|
|
#include <resultset.h>
|
|
#include <statement.h>
|
|
|
|
using namespace sql;
|
|
int main(void){
|
|
sql::Driver *driver;
|
|
sql::Connection *con;
|
|
sql::Statement *stmt;
|
|
sql::ResultSet *res;
|
|
|
|
driver = get_driver_instance();
|
|
con = driver->connect("tcp://ipaddress:3306","usr","pwd");
|
|
con->setSchema("timer_backend");
|
|
stmt = con->createStatement();
|
|
res = stmt->executeQuery("SELECT seconds FROM sessions;");
|
|
|
|
while (res->next()) {
|
|
std::cout << "\t... MySQL replies: ";
|
|
/* Access column data by alias or column name */
|
|
std::cout << res->getString("seconds") << std::endl;
|
|
std::cout << "\t... MySQL says it again: ";
|
|
/* Access column data by numeric offset, 1 is the first column */
|
|
std::cout << res->getString(1) << std::endl;
|
|
}
|
|
delete res;
|
|
delete stmt;
|
|
delete con;
|
|
|
|
return 0;
|
|
}
|