Quantcast
Channel: MySQL Forums - Connector/C++
Viewing all articles
Browse latest Browse all 527

Problem with C++ Connector (no replies)

$
0
0
Sorry, mi english is not very good, i've got this problem:
I'm using QT Creator and I am trying to make a conection between C++ and MySQL.

My code:

#include "mainwindow.h"
#include "ui_mainwindow.h"

#include <mysql_connection.h>
#include <cppconn/driver.h>
#include <cppconn/resultset.h>

#include <cppconn/statement.h>
#include <cppconn/exception.h>

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}

MainWindow::~MainWindow()
{
delete ui;
}

void MainWindow::on_pushButton_clicked()
{
sql::Driver *driver;
sql::Connection *connection;
sql::Statement *statement;
sql::ResultSet *resultset;

driver = get_driver_instance();
connection = driver->connect("tcp://127.0.0.1:331", "root", "");

connection->setSchema("remiseria");

statement = connection->createStatement();
resultset = statement->executeQuery("INSERT INTO city(name) VALUES ('villaguay') ");

delete resultset;
delete statement;
delete connection;

}


When I Run and Compile:

C:\Users\Pablo\Desktop\Remises\build-untitled-Desktop_Qt_5_3_MinGW_32bit-Debug\debug\mainwindow.o:-1: In function `ZN10MainWindow21on_pushButton_clickedEv':

C:\Users\Pablo\Desktop\Remises\untitled\mainwindow.cpp:32: error: undefined reference to `_imp__get_driver_instance'

collect2.exe:-1: error: error: ld returned 1 exit status

Thanks for your helps.

Viewing all articles
Browse latest Browse all 527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>