I'm having an issue with this. It keeps throwing the error:
use of class template 'std::unique_ptr' requires template arguments
I've searched for an hour. I've tried compiling using c++17, and still didn't work. How can I get the MariaDB Connector to work? I installed the MariaDB Connector. I am on Debian 10. And using clang++ v7 to compile. I tried adding a <template> option in the header, and still didn't work.
I'm compiling using this: clang++ -I/usr/include/mariadb/concpp/compat -O3 -Wall -o ./getUsers ./getUsers.cpp -lmariadbcpp
#include <iostream>
#include <cstring>
#include <mariadb/conncpp.hpp>
using namespace std;
// Main Process
int main(){
try {
// Instantiate Driver
sql::Driver* driver = sql::mariadb::get_driver_instance();
// Configure Connection
sql::SQLString url("jdbc:mariadb://x.x.x.x:3306/todo");
sql::Properties properties({{"user", "xxxx"}, {"password", "xxxx"}});
// Establish Connection
std::unique_ptr conn(driver->connect(url, properties));
// Create a new Statement
std::unique_ptr stmnt(conn->createStatement());
// Execute query
sql::ResultSet *res = stmnt->executeQuery("SELECT id, username FROM accounts");
// Loop through and print results
while (res->next()) {
std::cout << res->getInt("id") << ") ";
std::cout << res->getString("username");
}
}
catch(sql::SQLException& e){
std::cerr << "Error selecting tasks: " << e.what() << std::endl;
}
delete res;
delete stmnt;
delete conn;
// Exit (Success)
return 0;
}