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

The driver crash when calling driver->connect (2 replies)

$
0
0
Hi, I want to connect to a database using the cpp connector but the program crash when I'm trying to connect to the database :

sql::Driver* driver = get_driver_instance();
std::cout<<driver->getMajorVersion()<<","<<driver->getMinorVersion()<<std::endl<<"name : "<<driver->getName()<<std::endl;
if (driver == nullptr)
std::cout<<"failed to get driver"<<std::endl;
sql::Connection* con = driver->connect("tcp://127.0.0.1:3306", "root",password);
if (con == nullptr)
std::cout<<"failed to connect to database"<<std::endl;
con->setSchema("sorrok");

And the returning version is strange, version major is 0, version minor is 22 and name is empty.
And when I use sql::mysql::MySQL_Driver = sql::mysql::get_mysql_driver_instance I get an undefined reference error to sql::mysql::get_driver_instance.

“Can't connect … through socket '/tmp/mysql.sock'” using C API mysql_real_connect() (no replies)

$
0
0
Hi All


I'm running OS 11.1 Big Sur and updating an objective C program that uses the MySql C API (NOT the C Connector). I CAN connect to local MySql server from the command line using

/usr/local/mysql/bin/mysql --user=root --password=aPassword

but when my software tries to connect through the C API using mysql_real_connect(mSQLPtr, theHost, theLogin, thePass, theDatabase, 0, NULL, 0); it fails with:

Can't connect to local MySQL server through socket '/tmp/mysql.sock' (1)

I've read heaps of posts to try and fix it e.g. stopping and starting the server, checking that /tmp/mysql.sock file does exist after starting the server (AND IT DOES EXIST), and adding a my.cnf to the /etc folder. It contains:

[mysqld]
socket=/tmp/mysql.sock

[client]
socket=/tmp/mysql.sock

I've also done chmod 777 /tmp/mysql.sock

Nothing has worked so far. Can anyone offer any suggestions please.

Cheers Jeff

Indian restaurant croydon | Enjoy Delicious indian food | Delivery in croydon (no replies)

$
0
0
Indian dishes prepared fresh each day at our restaurant in croydon.Adeena's kitchen provide you home delivery .visit us! Our restaurant serves delicious.call on 02036678566.

error LNK2001 (no replies)

$
0
0
Hi,
I have problem when compiling my project with cpp connector:

1>mysqlcppconn-static.lib(mysql_connection.obj) : error LNK2001: nierozpoznany symbol zewnętrzny DnsFree
1>mysqlcppconn-static.lib(mysql_connection.obj) : error LNK2001: nierozpoznany symbol zewnętrzny DnsQuery_A
1>C:\Users\patry\Documents\visualstudio\SNAKE\x64\Release\SNAKE.exe : fatal error LNK1120: liczba nierozpoznanych elementów zewnętrznych: 2

I dont know what I am doing wrong, which lib I am missing.

Connector/C++ v 8 and binding parameters (4 replies)

$
0
0
I'm using the JDBC subset of the v 8 C++ connector. I can't find the equivalent of the mysql_stmt_bind_param function that was available in the 5.7 api. The 8.0 header prepared_statement.h has a bunch of functions, but none that seems parallel. How do I accomplish the same functionality using the 8.0 C++ connector?

MySQL Connector/C++ 8.0.23 has been released (no replies)

mysql_real_connect returns 0 (1 reply)

$
0
0
hi to all, I've mysql server in centos 6 VM and client in centos 7 VM. I've building a small project using c++ and mysql. when i want to connect to server in program it shows segmentation fault. And after searching for bug I got mysql_real_connect returns nullptr. I've created a class Conn and static function connection(); which i call as MYSQL *mysql = Conn::connection(); mine code is :-

MYSQL * Conn::connection()
{
//MY_INIT(argv[0]);

mysql_init(mysql);


if(mysql_library_init(0,NULL, NULL))
{
std::cout << "mysql lib init " << std::endl;
exit(1);
}
else
{
std::cout << "library initialized\t";
}
// mysql = mysql_init(NULL);
// mysql = mysql_init(nullptr);
mysql = mysql_init(mysql);
if(mysql == NULL)
{
std::cout<< "mysql connector is NULL";
//cin.get();
exit(2);
}
else
{
std::cout << "mysql_init initialised\t";
}

// conn = mysql_real_connect (&mysql,"serverora.db.net","rahul","rahul","cbs",3306,NULL,0);
mysql = mysql_real_connect (mysql,opt_host,opt_user_name,opt_password,opt_db_name,opt_port,opt_socket_name,opt_flags);
if(mysql == 0)
{
std::cout << "mysql_real_connect returned 0 : ";
return 0;
}
else
{
std::cout << "mysql initialized";
}
return mysql;
}
in header :-

#ifndef STAT_H_INCLUDED
#define STAT_H_INCLUDED

#include <my_global.h>
#include <my_sys.h>
#include "draw.h"
#include "getchoice.h"
#include "product.h"


#include<iostream>
#include<cstdio>
#include<fstream>
#include<sstream>
#include<string>
#include<cstdlib>
#include<mysql.h>
#include <vector>

class Conn;


static char *opt_host = "serverora.db.net";
static char *opt_user_name = "rahul";
static char *opt_password = "rahul";
static unsigned int opt_port = 3306;
static char *opt_socket_name = NULL;
static char *opt_db_name = "cbs";
static unsigned int opt_flags = 0;

class Conn // public Draw
{
Draw * draw;
int *totallen;
public:

std::vector<std::string> menu;
static MYSQL *mysql;
static int qstate;
static MYSQL_ROW row;
static MYSQL_RES *res;
static MYSQL_FIELD *field;

static MYSQL* connection();
static void printError(MYSQL *conn, char * message);

static bool dateValidity(std::string date);

static long intvalidity(std::string strnum);

Conn();
~Conn();
};

#endif // STAT_H_INCLUDED

code where error occured:-

void product::showAllProduct()
{
int times;
char choose;
clrscr();
drawrect();
int l = 5;
gotoxy(15, 5);

cout << "Welcome To Electronic Store";

gotoxy(15, 6);
cout << "Show All Items Menu\n";

string strQuery = "select *from tableProductRecords order by productname asc;";
gotoxy(1, 10);
mysql = Conn::connection();
cout << "mysql = " << mysql;

int qState = mysql_query(mysql, strQuery.c_str());// here error occures
if(!qState)
{
res = mysql_store_result(mysql);
int i = process_result_set(mysql, res, 10, &times, totallen);
}
else
{
cout << " error : " << " "<< mysql_error(mysql) << " " << endl;
}
cin.get();
}
output :-


library initialized mysql_init initialised mysql_real_connect returned 0 : mysql = 0

MySQL Connector/C++ 8.0.22 my app release build ok, debug build asserts TLS versions error (no replies)

$
0
0
TLS and application security in general are well outside my areas of expertise. I generally write instrument and machine interface software.
This is a large application, I have been unable to reproduce this problem in a simpler project. I have provided the compile/link commands because that seems like the most likely area for inception of the runtime error. All builds are completed with 0 errors/warnings using /w4 level.

Visual Studio 2019 Professional 16.8.5
Server version: 8.0.23 MySQL Community Server - GPL

MySQL Connector/C++ built from source:
OpenSSL 1.1.1d Static
MySQL Connector/C++ version : 8.0.22 Static (The "try" project runs without errors in Debug and Release)

According to the docs, I need to use this with a statically compiled connector (always errors out on connection if this is not set)
my.ini : default_authentication_plugin=mysql_native_password

The following works in Release build ( all program features work without errors/warnings) but fails to find tls_versions in Debug mode.
Error from our application's log: SetDbUrl setup failed with DB URL: mysqlx://user:pass@localhost:33060. DB Message: No supported TLS protocol version found in the 'tls-versions' list

std::string url = "mysqlx://user:pass@localhost:33060"
mysqlx::Session session( url );

I have included the compile/link commands below for the Connector/C++ build and for our application's build.

Connector/C++ Build commands (from project "connector" in solution "MySQL_CONCPP.sln"):

Debug Compile:
/ifcOutput "connector.dir\Debug\" /GS /TP /W3 /wd"4702" /wd"4297" /Zc:wchar_t /I"C:\Users\user.dom\Dev_Libraries\mysql-connector-cpp\mysql-connector-cpp-src\include" /I"C:\Users\user.dom\Dev_Libraries\mysql-connector-cpp\BUILD\common" /I"C:\Users\user.dom\Dev_Libraries\mysql-connector-cpp\mysql-connector-cpp-src\cdk\include" /I"C:\Users\user.dom\Dev_Libraries\mysql-connector-cpp\BUILD\cdk\include" /I"C:\Users\user.dom\Dev_Libraries\mysql-connector-cpp\mysql-connector-cpp-src\cdk\extra\rapidjson\include" /I"C:\Users\user.dom\Dev_Libraries\mysql-connector-cpp\mysql-connector-cpp-src\cdk\parser" /I"C:\Users\user.dom\Dev_Libraries\mysql-connector-cpp\mysql-connector-cpp-src\cdk\protobuf\protobuf-3.6.1\src" /Zi /Gm- /Od /Ob0 /Fd"connector.dir\Debug\connector.pdb" /Zc:inline /fp:precise /D "WIN32" /D "_WINDOWS" /D "RAPIDJSON_HAS_CXX11_NOEXCEPT=1" /D "RAPIDJSON_HAS_CXX11_RANGE_FOR=1" /D "RAPIDJSON_HAS_CXX11_RVALUE_REFS=1" /D "STATIC_CONCPP" /D "CMAKE_INTDIR=\"Debug\"" /D "_MBCS" /errorReport:prompt /WX- /Zc:forScope /RTC1 /GR /Gd /MDd /Fa"connector.dir\Debug\" /EHsc /nologo /Fo"connector.dir\Debug\" /Fp"connector.dir\Debug\mysqlcppconn8-static.pch" /diagnostics:column

Debug Link:
/OUT:"C:\Users\user.dom\Dev_Libraries\mysql-connector-cpp\BUILD\LIB\Debug\mysqlcppconn8-static.lib" /MACHINE:X64 /NOLOGO

Release Compile:
/ifcOutput "connector.dir\Release\" /GS /TP /W3 /wd"4702" /wd"4297" /Zc:wchar_t /I"C:\Users\user.dom\Dev_Libraries\mysql-connector-cpp\mysql-connector-cpp-src\include" /I"C:\Users\user.dom\Dev_Libraries\mysql-connector-cpp\BUILD\common" /I"C:\Users\user.dom\Dev_Libraries\mysql-connector-cpp\mysql-connector-cpp-src\cdk\include" /I"C:\Users\user.dom\Dev_Libraries\mysql-connector-cpp\BUILD\cdk\include" /I"C:\Users\user.dom\Dev_Libraries\mysql-connector-cpp\mysql-connector-cpp-src\cdk\extra\rapidjson\include" /I"C:\Users\user.dom\Dev_Libraries\mysql-connector-cpp\mysql-connector-cpp-src\cdk\parser" /I"C:\Users\user.dom\Dev_Libraries\mysql-connector-cpp\mysql-connector-cpp-src\cdk\protobuf\protobuf-3.6.1\src" /Gm- /O2 /Ob2 /Fd"connector.dir\Release\connector.pdb" /Zc:inline /fp:precise /D "WIN32" /D "_WINDOWS" /D "NDEBUG" /D "RAPIDJSON_HAS_CXX11_NOEXCEPT=1" /D "RAPIDJSON_HAS_CXX11_RANGE_FOR=1" /D "RAPIDJSON_HAS_CXX11_RVALUE_REFS=1" /D "STATIC_CONCPP" /D "CMAKE_INTDIR=\"Release\"" /D "_MBCS" /errorReport:prompt /WX- /Zc:forScope /GR /Gd /MD /Fa"connector.dir\Release\" /EHsc /nologo /Fo"connector.dir\Release\" /Fp"connector.dir\Release\mysqlcppconn8-static.pch" /diagnostics:column

Release Link:
/OUT:"C:\Users\user.dom\Dev_Libraries\mysql-connector-cpp\BUILD\LIB\Release\mysqlcppconn8-static.lib" /MACHINE:X64 /NOLOGO

Application build commands (from our application)

Debug Compile:
/JMC /permissive- /Yu"pch.h" /MP /ifcOutput "C:\Users\user.dom\Documents\_Projects\our_company\trunk\Build\Debug\our_product\Obj\" /GS /TP /W4 /wd"4068" /wd"4996" /wd"26444" /wd"26812" /wd"26439" /wd"26495" /Zc:wchar_t /I"C:\Users\user.dom\Documents\_Projects\our_company\trunk\our_product\\source\" /I"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\libplctag\include\" /I"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\mysql_connector\include\" /I"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\wxWidgets\include\" /I"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\spdlog\include\" /I"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\ChartDirector\include\" /I"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\opencv\include\" /I"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\fmt\include" /I"C:\Program Files\Basler\pylon 6\Development\\include\" /I"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\wxWidgets\debug\mswud\" /I"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\wxWidgets\include\msvc" /I"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\wxWidgets\include" /ZI /Gm- /Od /Ob0 /sdl /Fd"C:\Users\user.dom\Documents\_Projects\our_company\trunk\Build\Debug\our_product\Obj\vc142.pdb" /FI"pch.h" /fp:precise /D "WIN32_LEAN_AND_MEAN" /D "STATIC_CONCPP" /D "WIN32" /D "_CRT_SECURE_NO_DEPRECATE=1" /D "_CRT_NON_CONFORMING_SWPRINTFS=1" /D "_SCL_SECURE_NO_WARNINGS=1" /D "__WXMSW__" /D "_UNICODE" /D "UNICODE" /D "_WINDOWS" /D "_DEBUG" /D "_CRTDBG_MAP_ALLOC" /D "_MBCS" /errorReport:prompt /WX- /Zc:forScope /RTC1 /GR /Gd /MDd /std:c++17 /FC /Fa"C:\Users\user.dom\Documents\_Projects\our_company\trunk\Build\Debug\our_product\Obj\" /EHsc /nologo /Fo"C:\Users\user.dom\Documents\_Projects\our_company\trunk\Build\Debug\our_product\Obj\" /Fp"C:\Users\user.dom\Documents\_Projects\our_company\trunk\Build\Debug\our_product\Obj\our_product.pch" /diagnostics:column

Debug Link:
/OUT:"C:\Users\user.dom\Documents\_Projects\our_company\trunk\Build\Debug\our_product\our_product.exe" /MANIFEST /NXCOMPAT /PDB:"C:\Users\user.dom\Documents\_Projects\our_company\trunk\Build\Debug\our_product\our_product.pdb" /DYNAMICBASE "chartdir60.lib" "GCBase_MD_VC141_v3_1_Basler_pylon.lib" "GenApi_MD_VC141_v3_1_Basler_pylon.lib" "PylonBase_v6_0.lib" "PylonC.lib" "PylonGUI_v6_0.lib" "PylonUtility_v6_0.lib" "fmtd.lib" "spdlogd.lib" "opencv_world440d.lib" "Ws2_32.lib" "Iphlpapi.lib" "plctag.lib" "wxmsw31ud_core.lib" "wxbase31ud.lib" "wxmsw31ud_aui.lib" "wxtiffd.lib" "wxjpegd.lib" "wxpngd.lib" "wxzlibd.lib" "wxregexud.lib" "wxexpatd.lib" "wxmsw31ud_media.lib" "mysqlcppconn8-static_debug.lib" "ws2_32.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "comdlg32.lib" "winspool.lib" "winmm.lib" "shell32.lib" "shlwapi.lib" "comctl32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "rpcrt4.lib" "advapi32.lib" "version.lib" "wsock32.lib" "wininet.lib" "Wldap32.lib" "Crypt32.lib" "DnsApi.lib" "odbc32.lib" "odbccp32.lib" /LARGEADDRESSAWARE /DEBUG:FULL /MACHINE:X64 /OPT:NOREF /INCREMENTAL /PGD:"C:\Users\user.dom\Documents\_Projects\our_company\trunk\Build\Debug\our_product\our_product.pgd" /SUBSYSTEM:WINDOWS /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"C:\Users\user.dom\Documents\_Projects\our_company\trunk\Build\Debug\our_product\Obj\our_product.exe.intermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /VERBOSE:Lib /LIBPATH:"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\ChartDirector\" /LIBPATH:"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\openssl\" /LIBPATH:"C:\Program Files\Basler\pylon 6\Development\\lib\x64\" /LIBPATH:"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\wxWidgets\debug\" /LIBPATH:"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\mysql_connector\debug\" /LIBPATH:"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\mysql_connector\" /LIBPATH:"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\libplctag\debug\" /LIBPATH:"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\spdlog\debug\" /LIBPATH:"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\opencv\debug\" /LIBPATH:"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\fmt\debug\" /LIBPATH:"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\wxWidgets\lib\vc_x64_lib" /TLBID:1

Release Compile:
/permissive- /Yu"pch.h" /MP /ifcOutput "C:\Users\user.dom\Documents\_Projects\our_company\trunk\Build\Release\our_product\Obj\" /GS /TP /GL /W4 /wd"4068" /wd"4996" /wd"26444" /wd"26812" /wd"26439" /wd"26495" /Zc:wchar_t /I"C:\Users\user.dom\Documents\_Projects\our_company\trunk\our_product\\source\" /I"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\libplctag\include\" /I"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\mysql_connector\include\" /I"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\wxWidgets\include\" /I"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\spdlog\include\" /I"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\ChartDirector\include\" /I"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\opencv\include\" /I"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\fmt\include" /I"C:\Program Files\Basler\pylon 6\Development\\include\" /I"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\wxWidgets\release\mswu\" /I"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\wxWidgets\include\msvc" /I"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\wxWidgets\include" /Zi /Gm- /O2 /sdl /Fd"C:\Users\user.dom\Documents\_Projects\our_company\trunk\Build\Release\our_product\Obj\vc142.pdb" /FI"pch.h" /Zc:inline /fp:precise /D "WIN32_LEAN_AND_MEAN" /D "STATIC_CONCPP" /D "WIN32" /D "_CRT_SECURE_NO_DEPRECATE=1" /D "_CRT_NON_CONFORMING_SWPRINTFS=1" /D "_SCL_SECURE_NO_WARNINGS=1" /D "__WXMSW__" /D "_UNICODE" /D "UNICODE" /D "_WINDOWS" /D "NDEBUG" /D "_MBCS" /errorReport:prompt /WX- /Zc:forScope /GR /Gd /Oi /MD /std:c++17 /FC /Fa"C:\Users\user.dom\Documents\_Projects\our_company\trunk\Build\Release\our_product\Obj\" /EHsc /nologo /Fo"C:\Users\user.dom\Documents\_Projects\our_company\trunk\Build\Release\our_product\Obj\" /Fp"C:\Users\user.dom\Documents\_Projects\our_company\trunk\Build\Release\our_product\Obj\our_product.pch" /diagnostics:column

Release Link:
/OUT:"C:\Users\user.dom\Documents\_Projects\our_company\trunk\Build\Release\our_product\our_product.exe" /MANIFEST /LTCG:incremental /NXCOMPAT /PDB:"C:\Users\user.dom\Documents\_Projects\our_company\trunk\Build\Release\our_product\our_product.pdb" /DYNAMICBASE "chartdir60.lib" "GCBase_MD_VC141_v3_1_Basler_pylon.lib" "GenApi_MD_VC141_v3_1_Basler_pylon.lib" "PylonBase_v6_0.lib" "PylonC.lib" "PylonGUI_v6_0.lib" "PylonUtility_v6_0.lib" "fmt.lib" "spdlog.lib" "opencv_world440.lib" "Ws2_32.lib" "Iphlpapi.lib" "plctag.lib" "wxmsw31u_core.lib" "wxbase31u.lib" "wxmsw31u_aui.lib" "wxtiff.lib" "wxjpeg.lib" "wxpng.lib" "wxzlib.lib" "wxregexu.lib" "wxexpat.lib" "wxmsw31u_media.lib" "mysqlcppconn8-static.lib" "ws2_32.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "comdlg32.lib" "winspool.lib" "winmm.lib" "shell32.lib" "shlwapi.lib" "comctl32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "rpcrt4.lib" "advapi32.lib" "version.lib" "wsock32.lib" "wininet.lib" "Wldap32.lib" "Crypt32.lib" "DnsApi.lib" "odbc32.lib" "odbccp32.lib" /LARGEADDRESSAWARE /DEBUG:FASTLINK /MACHINE:X64 /OPT:REF /INCREMENTAL:NO /PGD:"C:\Users\user.dom\Documents\_Projects\our_company\trunk\Build\Release\our_product\our_product.pgd" /SUBSYSTEM:WINDOWS /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"C:\Users\user.dom\Documents\_Projects\our_company\trunk\Build\Release\our_product\Obj\our_product.exe.intermediate.manifest" /OPT:ICF /ERRORREPORT:PROMPT /NOLOGO /VERBOSE:Lib /LIBPATH:"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\ChartDirector\" /LIBPATH:"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\openssl\" /LIBPATH:"C:\Program Files\Basler\pylon 6\Development\\lib\x64\" /LIBPATH:"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\wxWidgets\release\" /LIBPATH:"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\mysql_connector\" /LIBPATH:"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\libplctag\" /LIBPATH:"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\spdlog\" /LIBPATH:"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\opencv\" /LIBPATH:"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\fmt\" /LIBPATH:"C:\Users\user.dom\Documents\_Projects\our_company\trunk\lib\wxWidgets\lib\vc_x64_lib" /TLBID:1

Is the Connector thread-safe? (no replies)

$
0
0
Hello. Where is the information about whether the connector is thread-safe? Can I call the execute method in different threads and be sure that the execution is correct? If not, which methods share the same mutable data? I mean, can I make a thread for the execute methods and use the with mutex query pool, and still continue to call the getSchema method in another thread without synchronization?

c++ and Exlipse (no replies)

$
0
0
After adding the MySQL Connector c++ using the windows msi installers I copied the sample project, but am receiving the following errors during linking

C:/Program Files/MySQL/Connector C++ 8.0/include/jdbc/cppconn/driver.h:77: undefined reference to `check(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
C:/Program Files/MySQL/Connector C++ 8.0/include/jdbc/cppconn/driver.h:78: undefined reference to `check(std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > const&)'
Trading.o: In function `get_driver_instance_by_name':
C:/Program Files/MySQL/Connector C++ 8.0/include/jdbc/cppconn/driver.h:90: undefined reference to `_get_driver_instance_by_name'
collect2.exe: error: ld returned 1 exit status

I am using eclipse for the IDE. Any help would be appreciated.

Dynamic Var Bind with Multi Statement query in Mysql (1 reply)

$
0
0
Hi ,

I want to use Multi statement query with Dynamic Var bind so just wants to know it's valid combination or not i.e. - can we use both together ?

status =mysql_query(con,"query1;query2");

query1 & query2 is having dynamic Var<? , ?> so can we use with Multi statement .

Please help me out on same .

Regards
Ravindra

MySQL Connector/C++ 8.0.24 has been released (no replies)

MySQL Connector/C++ 8.0.25 has been released (no replies)

How to escape a string? (3 replies)

$
0
0
Connector/C++ 8.0.25 (Legacy JDBC API)

How do I escape a string without using a PreparedStatement and setString(index, value)?

All the other mysql connectors seem to have a 'mysql_real_escape_string' type function. I can not seem to find anything similar with Connector/C++.

The issue with using a PreparedStatement and setString() is our code currently can issue one insert statement with multiple insert rows. Inserting each row one insert at a time will slow down our processing.

Note: I'm in the middle of migrating our code from Connector/C & MySQL++ to Connector/C++. We are upgrading to a new server with MySQL 8.0. And as far as I have found, the Windows version of Connector/C only goes up to 6.1.11. At least via the MySQL installer and the MySQL download page. And Connector/C 6.1.11 can not authenticate against a MySQL 8.0 db without enabling legacy authentication. And we are trying to avoid that.

How do I get the session state (and then reconnect)? (4 replies)

$
0
0
Hello. How can I get the mysqlx::Session state using XDevApi for C++? Let's say the MySQL server has dropped the connection, how can I check it?

My client can work for several weeks without shutting down and sending queries. A few hours after starting and sending the query, I get an exception. As far as I understand, this is due to the "wait_timeout" property, which disconnect the session from the server. Actually, how do I check that there was a disconnection and then reconnect?

I didn't find any method in mysqlx::Session that could help me.

undefined reference to `get_driver_instance' (1 reply)

$
0
0
Hi, I have compile failure for c++ embedded mysql. The program is very simple. I have included the direct paths for all of the headerfiles in include and its subdirectory cppconn.
using namespace std;
using namespace sql;
int main(){
Driver *driver;
Connection *con;
driver = get_driver_instance();
con = driver -> connect(host, username, password);
con -> setSchema(db);
con -> close(); }

The error: /tmp/cc1YxUfU.o: In function `main':
sqlTest.cpp:(.text+0xd): undefined reference to `sql::mysql::get_mysql_driver_instance()'
collect2: error: ld returned 1 exit status

I have tested a couple compile methods, but to no avail.
g++ sqlTest.cpp -o test
g++ -Wall -I/home/ryanh/mysql-connector-c++-noinstall-1.0.5-winx64/include/cppconn -o test sqlTest.cpp -L/home/ryanh/mysql-connector-c++-noinstall-1.0.5-winx64/lib

After some research some people suggested using -lmysqlcppconn, but I have no idea what that is or what it does. When I use it in the compile it says it does not exist.

A hello world compiles with the headers and runs without the use of any functions or anything.

I tried creating an object of driver class MySQL_Driver *driver and use its function get_mysql_driver_instance, but it has the same corresponding error saying it is an undefined reference.

Help would be appreciated thanks.

MySQL Connector/C++ 8.0.26 is released (no replies)

mysql-connector-c++-8.0.26-src compiler error (no replies)

$
0
0
mysql-connector-c++-8.0.26-src/jdbc/driver/mysql_connection.cpp:305:31: error: ‘MYSQL_OPT_LOAD_DATA_LOCAL_DIR’ was not declared in this scope
{OPT_LOAD_DATA_LOCAL_DIR, MYSQL_OPT_LOAD_DATA_LOCAL_DIR, false}
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/matrixai/quycTest/src/mysql-connector-c++-8.0.26-src/jdbc/driver/mysql_connection.cpp:305:31: note: suggested alternative: ‘OPT_LOAD_DATA_LOCAL_DIR’
{OPT_LOAD_DATA_LOCAL_DIR, MYSQL_OPT_LOAD_DATA_LOCAL_DIR, false}
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
OPT_LOAD_DATA_LOCAL_DIR
/home/matrixai/quycTest/src/mysql-connector-c++-8.0.26-src/jdbc/driver/mysql_connection.cpp: In member function ‘virtual sql::Connection* sql::mysql::MySQL_Connection::setClientOption(const sql::SQLString&, const void*)’:
/home/matrixai/quycTest/src/mysql-connector-c++-8.0.26-src/jdbc/driver/mysql_connection.cpp:1639:20: error: ‘MYSQL_OPT_LOAD_DATA_LOCAL_DIR’ was not declared in this scope
proxy->options(MYSQL_OPT_LOAD_DATA_LOCAL_DIR, optionValue);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/matrixai/quycTest/src/mysql-connector-c++-8.0.26-src/jdbc/driver/mysql_connection.cpp:1639:20: note: suggested alternative: ‘OPT_LOAD_DATA_LOCAL_DIR’
proxy->options(MYSQL_OPT_LOAD_DATA_LOCAL_DIR, optionValue);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
OPT_LOAD_DATA_LOCAL_DIR
jdbc/driver/CMakeFiles/jdbc.dir/build.make:107: recipe for target 'jdbc/driver/CMakeFiles/jdbc.dir/mysql_connection.cpp.o' failed


mysql version:mysql Ver 14.14 Distrib 5.7.34, for Linux (aarch64) using EditLine wrapper

C++ mySQL connection failed (15 replies)

$
0
0
I have created a VST plugin with JUCE. I have created a database that asks whether a serial number is available.

After the user has logged in, he can log out. However, you have to log out after a few seconds, otherwise the connection gives me an error. If I wait longer than 5 seconds and click log out, nothing happens. I found out that this was created incorrectly at mysql_real_connect. No values ​​are read.

CODE:
int SQLLogout() {
MYSQL* conn;
MYSQL_ROW row;
MYSQL_RES* res;
char* key;
conn = mysql_init(0);

int ID;
std::ifstream infile("ID.txt");
infile >> ID;
infile.close();
mysql_real_connect(conn, "localhost", "root", "", "eq", 3306, NULL, 0); //this line is the problem

if (conn) {


std::ostringstream str;
str << "SELECT * FROM users WHERE UserID=" << ID;
std::string sql = str.str();

qstate = mysql_query(conn, sql.c_str());
if (!qstate) {
res = mysql_store_result(conn);
if (res->row_count == 0) {
return 0;
}
while (row = mysql_fetch_row(res)) {
if (atoi(row[0]) == ID) {

std::ostringstream str;
str << "UPDATE users SET Aktiv=0 WHERE (UserID=" << ID << ");";
std::string sql = str.str();

mysql_query(conn, sql.c_str());

std::ofstream outfile;
outfile.open("ID.txt"/*, std::ofstream::out | std::ofstream::trunc */ );
outfile << "0";
outfile.close();


WinExec("EQ.exe", 42);
std::quick_exit(42);
return 1;
}
}
}
else {
return 2;
}
}
else {
return 3;
}
}


CODE:
Logout.onClick = [this] {Logout.setClickingTogglesState(true); };
if (Logout.getClickingTogglesState() == true) {
SQLLogout();
}
the same is as soon as I enter the serial number, if I wait longer and in the meantime enter the serial number and this confirms an SQL error. The data were not read from mysql_real_connect

Does anyone know how I can solve this? Thanks in advance

Connector c++ 8 error looking for SSL Library (no replies)

$
0
0
I am unable to perform the configuration step for making the library on mac os,
When I issue this command:

cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/connector-c++-8.0 -WITH_SSL=system -DBUILD_STATIC=ON

I get the following error:

-- Looking for SSL library.
CMake Error at cdk/cmake/DepFindSSL.cmake:79 (message):
Cannot find appropriate system libraries for SSL. Make sure you've
specified a supported SSL version. Consult the documentation for WITH_SSL
alternatives
Call Stack (most recent call first):
cdk/cmake/DepFindSSL.cmake:354 (main)
cdk/cmake/dependency.cmake:42 (include)
cdk/CMakeLists.txt:96 (find_dependency)

I had no problem making the library on Ubuntu, piece of cake, how to fix this for mac os?
Viewing all 527 articles
Browse latest View live