#include <stdlib.h>
#include <iostream>

#include "mysql_connection.h"
#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>

using namespace std;

int main(void) {

	try {
	  sql::Driver *driver;
	  sql::Connection *con;
	  sql::Statement *stmt;
	  sql::ResultSet *res;

	  driver = get_driver_instance();
	  con = driver->connect("", "", "");
	  con->setSchema("gif");

	  stmt = con->createStatement();
	  res = stmt->executeQuery("SELECT * FROM student");
	  while (res->next()) {
		cout << res->getString("name") << ", ";
		cout << res->getString("vorname") << endl;
	  }
	  delete res;
	  delete stmt;
	  delete con;

	} catch (sql::SQLException &e) {
	  cout << "ERROR: " << e.what();
	  cout << " MySQL error code: " << e.getErrorCode() << endl;
	}

	cout << endl;

	return 0;
}