MySQL Forums
Forum List  »  Connector/C++

Problem with C++ Connector
Posted by: yo argentino
Date: August 08, 2014 01:08PM

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.

Options: ReplyQuote


Subject
Views
Written By
Posted
Problem with C++ Connector
3167
August 08, 2014 01:08PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.