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

Help setting up mysql C++ connector in visual studio and ubuntu (no replies)

$
0
0
Hi I'm willing to pay $200 for help setting up the mysql C++ connector for xdevapi in visual studio and ubuntu. Please let me know if you can help.
my discord is: conor#8014

thanks!

Mysql C++ connector: (process 26464) exited with code -1073740791. (no replies)

$
0
0
Set project to release x64

C/C++->General->Additional Include Directories:
C:\Program Files\MySQL\Connector C++ 8.0\include

Linker->General->Additional Library Directories:
C:\Program Files\MySQL\Connector C++ 8.0\lib64\vs14



#include <iostream>

#include <mysqlx/xdevapi.h>

int main()
{
mysqlx::Session sess("localhost", 3306, "root", "password");
mysqlx::Schema db = sess.getSchema("schema_name");
std::getchar();
}


when running my program, I get the error:

C:\Users\Conor\source\repos\mysql_test\x64\Release\mysql_test.exe (process 26464) exited with code -1073740791.
Press any key to close this window . . .

CDK Error: no such file or directory (generic:2) (no replies)

$
0
0
Hi guys:

There is a longblob type field in my table. When I use the table:: insert() interface to insert, the code will exception and get a prompt: CDK error: no such file or directory (generic:2).

After many tests, I found that as long as the amount of inserted data is reduced to less than 60m, the insertion can succeed, otherwise exceptions will occur.

Does this mean that my code is correct, but there is an error in the MySQL configuration item.

I have set "max_allowed_packet" to 2G, but the exception still exists.

Guys, do you have any suggestions for this.

C++ OO programming usage (no replies)

$
0
0
I'm just getting started in programming with MySQL 8/Connector C++. Everything is built and linked and working but I have a question about how to make use of this in a true C++ Object Oriented program.

All of the classes require full configuration on instantiation. That means, for example, that I could NOT do this in my own class definition:

class myClass {
public:
mysqlx::Session mySession;
mysqlx::Table myTable;

etc...
};

where I would instantiate an object of myClass and the configure myClass.mySession, myClass.myTable, and so on.

That seems to say that not only can I not make use of object oriented programming but I also can't make use of functions, because every function that I want to use to access the database I will have to locally instantiate Session and Table objects, so I end up duplicating a lot of code.

What am I missing?

MySQL 8.0.30: Release Notes (no replies)

$
0
0

Reading DATE, DATETIME via mysqlx (MySQL Connector/C++ 8.0 X DevAPI) (no replies)

$
0
0
Since this is still not implemented into the C++ Connector we developed the following C++20 helper methods for production use with mysqlx (MySQL Connector/C++ 8.0 X DevAPI) to properly read DATE, DATETIME and TIMESTAMP fields:

#pragma once

#include <vector>
#include <cstddef>
#include <chrono>
#include <mysqlx/xdevapi.h>

namespace mysqlx {

static inline std::vector<uint64_t>
mysqlx_raw_as_u64_vector(const mysqlx::Value& in_value)
{
std::vector<uint64_t> out;

const auto bytes = in_value.getRawBytes();
auto ptr = reinterpret_cast<const std::byte*>(bytes.first);
auto end = reinterpret_cast<const std::byte*>(bytes.first) + bytes.second;

while (ptr != end) {
static constexpr std::byte carry_flag{0b1000'0000};
static constexpr std::byte value_mask{0b0111'1111};

uint64_t v = 0;
uint64_t shift = 0;
bool is_carry;
do {
auto byte = *ptr;
is_carry = (byte & carry_flag) == carry_flag;
v |= std::to_integer<uint64_t>(byte & value_mask) << shift;

++ptr;
shift += 7;
} while (is_carry && ptr != end && shift <= 63);

out.push_back(v);
}

return out;
}

static inline std::chrono::year_month_day
read_date(const mysqlx::Value& value)
{
const auto vector = mysqlx_raw_as_u64_vector(value);
if (vector.size() < 3)
throw std::out_of_range{"Value is not a valid DATE"};

return std::chrono::year{static_cast<int>(vector.at(0))} / static_cast<int>(vector.at(1)) / static_cast<int>(vector.at(2));
}

static inline std::chrono::system_clock::time_point
read_date_time(const mysqlx::Value& value)
{
const auto vector = mysqlx_raw_as_u64_vector(value);
if (vector.size() < 3)
throw std::out_of_range{"Value is not a valid DATETIME"};

auto ymd = std::chrono::year{static_cast<int>(vector.at(0))} / static_cast<int>(vector.at(1)) / static_cast<int>(vector.at(2));
auto sys_days = std::chrono::sys_days{ymd};

auto out = std::chrono::system_clock::time_point(sys_days);

auto it = vector.begin() + 2;
auto end = vector.end();

if (++it == end)
return out;
out += std::chrono::hours{*it};

if (++it == end)
return out;
out += std::chrono::minutes{*it};

if (++it == end)
return out;
out += std::chrono::seconds{*it};

if (++it == end)
return out;
out += std::chrono::microseconds{*it};

return out;
}

} //namespace



Which can then be used as follows:



auto row = table.select("datetime", "date").execute().fetchOne();
auto time_point = read_date_time(row[0]);
auto year_month_day = read_date(row[1]);



rgds Kira

Binding Blob with xdevapi (no replies)

$
0
0
I am trying to bind a char * to a blob parameter. The data contains special characters(eg. €). Is there any way of implementation?

cmake error when using xdevapi (no replies)

$
0
0
hello there

i finally managed to include this lib in my project by installing

mysql-apt-config_0.8.24-1_all.deb
mysql-community-client-plugins
libmysqlcppconn8-2_8.0.31-1ubuntu22.04_amd64.deb
libmysqlcppconn9_8.0.31-1ubuntu22.04_amd64.deb
libmysqlcppconn-dev_8.0.31-1ubuntu22.04_amd64.deb

i dont know why it has to be so complicated

now when i work in IDE everything seems fine i can navigate myself to declarations in /usr/include/mysql-cppconn-8/mysqlx/xdevapi.h but when im trying to build and compile im getting error

this is very simplified representation of my cmake config

add_library(MySQL MySQL.h MySQL.cpp)
target_link_libraries(MySQL PUBLIC Config mysqlcppconn)
add_executable(Auth Auth/Main.cpp)

inside MySQL.cpp i have

#include <mysql-cppconn-8/mysqlx/xdevapi.h>

just including it already causes this

FAILED: Servers/Auth
: && /usr/bin/c++ -g Servers/CMakeFiles/Auth.dir/Auth/Main.cpp.o -o Servers/Auth Core/Models/Auth/libAccount.a Core/Models/libModel.a Database/MySQL/libMySQL.a Config/libConfig.a Support/libDotEnv.a -lmysqlcppconn && :
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): warning: relocation against `_ZTVN6mysqlx4abi22r05DbDocE' in read-only section `.text._ZN6mysqlx4abi22r05DbDocD2Ev[_ZN6mysqlx4abi22r05DbDocD5Ev]'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::string::traits<char>::to_str[abi:cxx11](mysqlx::abi2::r0::string const&)':
/usr/include/mysql-cppconn-8/mysqlx/devapi/common.h:225: undefined reference to `mysqlx::abi2::r0::string::Impl::to_utf8[abi:cxx11](mysqlx::abi2::r0::string const&)'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::DbDoc::DbDoc()':
/usr/include/mysql-cppconn-8/mysqlx/devapi/document.h:107: undefined reference to `vtable for mysqlx::abi2::r0::DbDoc'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::DbDoc::~DbDoc()':
/usr/include/mysql-cppconn-8/mysqlx/devapi/document.h:81: undefined reference to `vtable for mysqlx::abi2::r0::DbDoc'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::Value::print(std::ostream&) const':
/usr/include/mysql-cppconn-8/mysqlx/devapi/document.h:508: undefined reference to `mysqlx::abi2::r0::common::Value::print(std::ostream&) const'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o):(.data.rel.ro._ZTCN6mysqlx4abi22r05ValueE0_NS1_6common5ValueE[_ZTVN6mysqlx4abi22r05ValueE]+0x18): undefined reference to `typeinfo for mysqlx::abi2::r0::common::Value'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o):(.data.rel.ro._ZTCN6mysqlx4abi22r05ValueE0_NS1_6common5ValueE[_ZTVN6mysqlx4abi22r05ValueE]+0x20): undefined reference to `mysqlx::abi2::r0::common::Value::print(std::ostream&) const'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o):(.data.rel.ro._ZTIN6mysqlx4abi22r05ValueE[_ZTIN6mysqlx4abi22r05ValueE]+0x28): undefined reference to `typeinfo for mysqlx::abi2::r0::common::Value'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

and when i add actual code to execute simple select it gives this

FAILED: Servers/Auth
: && /usr/bin/c++ -g Servers/CMakeFiles/Auth.dir/Auth/Main.cpp.o -o Servers/Auth Core/Models/Auth/libAccount.a Core/Models/libModel.a Database/MySQL/libMySQL.a Config/libConfig.a Support/libDotEnv.a -lmysqlcppconn && :
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): warning: relocation against `_ZTVN6mysqlx4abi22r06common5ValueE' in read-only section `.text._ZN6mysqlx4abi22r06common5ValueD1Ev[_ZN6mysqlx4abi22r06common5ValueD1Ev]'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::common::Settings_impl::Data::Data()':
/usr/include/mysql-cppconn-8/mysqlx/common/settings.h:217: undefined reference to `mysqlx::abi2::r0::common::Settings_impl::Data::init_connection_attr()'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::common::Value::~Value()':
/usr/include/mysql-cppconn-8/mysqlx/common/value.h:61: undefined reference to `vtable for mysqlx::abi2::r0::common::Value'
/usr/bin/ld: /usr/include/mysql-cppconn-8/mysqlx/common/value.h:61: undefined reference to `vtable for mysqlx::abi2::r0::common::Value'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::string::traits<char>::from_str(mysqlx::abi2::r0::string&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/usr/include/mysql-cppconn-8/mysqlx/devapi/common.h:220: undefined reference to `mysqlx::abi2::r0::string::Impl::from_utf8(mysqlx::abi2::r0::string&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::string::traits<char>::to_str[abi:cxx11](mysqlx::abi2::r0::string const&)':
/usr/include/mysql-cppconn-8/mysqlx/devapi/common.h:225: undefined reference to `mysqlx::abi2::r0::string::Impl::to_utf8[abi:cxx11](mysqlx::abi2::r0::string const&)'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::DbDoc::DbDoc()':
/usr/include/mysql-cppconn-8/mysqlx/devapi/document.h:107: undefined reference to `vtable for mysqlx::abi2::r0::DbDoc'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::DbDoc::~DbDoc()':
/usr/include/mysql-cppconn-8/mysqlx/devapi/document.h:81: undefined reference to `vtable for mysqlx::abi2::r0::DbDoc'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::Value::print(std::ostream&) const':
/usr/include/mysql-cppconn-8/mysqlx/devapi/document.h:508: undefined reference to `mysqlx::abi2::r0::common::Value::print(std::ostream&) const'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::DbDoc::DbDoc(mysqlx::abi2::r0::DbDoc const&)':
/usr/include/mysql-cppconn-8/mysqlx/devapi/document.h:81: undefined reference to `vtable for mysqlx::abi2::r0::DbDoc'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::Row::get(unsigned long)':
/usr/include/mysql-cppconn-8/mysqlx/devapi/row.h:162: undefined reference to `mysqlx::abi2::r0::internal::Row_detail::get_val(unsigned long)'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::Row::set(unsigned long, mysqlx::abi2::r0::Value const&)':
/usr/include/mysql-cppconn-8/mysqlx/devapi/row.h:180: undefined reference to `mysqlx::abi2::r0::internal::Row_detail::get_val(unsigned long)'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::Row::operator[](unsigned long)':
/usr/include/mysql-cppconn-8/mysqlx/devapi/row.h:208: undefined reference to `mysqlx::abi2::r0::internal::Row_detail::ensure_impl()'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::internal::Row_result_detail<mysqlx::abi2::r0::Columns>::~Row_result_detail()':
/usr/include/mysql-cppconn-8/mysqlx/devapi/detail/result.h:314: undefined reference to `mysqlx::abi2::r0::internal::Result_detail::~Result_detail()'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::TableSelect::TableSelect(mysqlx::abi2::r0::Table&)':
/usr/include/mysql-cppconn-8/mysqlx/devapi/table_crud.h:266: undefined reference to `mysqlx::abi2::r0::internal::Crud_factory::mk_select(mysqlx::abi2::r0::Table&)'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::internal::Schema_detail::Name_src::~Name_src()':
/usr/include/mysql-cppconn-8/mysqlx/devapi/detail/session.h:178: undefined reference to `mysqlx::abi2::r0::internal::Query_src::~Query_src()'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::internal::Schema_detail::Table_src::Table_src(mysqlx::abi2::r0::Schema const&, mysqlx::abi2::r0::string const&)':
/usr/include/mysql-cppconn-8/mysqlx/devapi/detail/session.h:205: undefined reference to `mysqlx::abi2::r0::internal::Schema_detail::Name_src::Name_src(mysqlx::abi2::r0::Schema const&, mysqlx::abi2::r0::internal::Schema_detail::Obj_type, mysqlx::abi2::r0::string const&)'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::internal::Session_detail::~Session_detail()':
/usr/include/mysql-cppconn-8/mysqlx/devapi/detail/session.h:379: undefined reference to `mysqlx::abi2::r0::internal::Session_detail::close()'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::Session::Session(mysqlx::abi2::r0::SessionSettings)':
/usr/include/mysql-cppconn-8/mysqlx/xdevapi.h:1684: undefined reference to `mysqlx::abi2::r0::internal::Session_detail::Session_detail(mysqlx::abi2::r0::common::Settings_impl&)'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `void mysqlx::abi2::r0::internal::Row_detail::set_values<mysqlx::abi2::r0::Value>(unsigned long, mysqlx::abi2::r0::Value)':
/usr/include/mysql-cppconn-8/mysqlx/devapi/detail/row.h:96: undefined reference to `mysqlx::abi2::r0::internal::Row_detail::ensure_impl()'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::internal::Row_result_detail<mysqlx::abi2::r0::Columns>::get_row()':
/usr/include/mysql-cppconn-8/mysqlx/devapi/detail/result.h:372: undefined reference to `mysqlx::abi2::r0::internal::Row_result_detail<mysqlx::abi2::r0::Columns>::iterator_next()'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::internal::Result_common<mysqlx::abi2::r0::internal::Row_result_detail<mysqlx::abi2::r0::Columns> >::Result_common(mysqlx::abi2::r0::common::Result_init&)':
/usr/include/mysql-cppconn-8/mysqlx/devapi/result.h:149: undefined reference to `mysqlx::abi2::r0::internal::Row_result_detail<mysqlx::abi2::r0::Columns>::Row_result_detail(mysqlx::abi2::r0::common::Result_init&)'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::internal::Iterator<mysqlx::abi2::r0::internal::Schema_detail::Table_src, mysqlx::abi2::r0::Table, long, mysqlx::abi2::r0::Table*, mysqlx::abi2::r0::Table&>::operator*() const':
/usr/include/mysql-cppconn-8/mysqlx/devapi/common.h:441: undefined reference to `mysqlx::abi2::r0::internal::Schema_detail::Table_src::iterator_get()'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `void mysqlx::abi2::r0::internal::Settings_detail<mysqlx::abi2::r0::internal::Settings_traits>::set<true, mysqlx::abi2::r0::SessionOption, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, mysqlx::abi2::r0::SessionOption::Enum, unsigned int&, mysqlx::abi2::r0::SessionOption::Enum, mysqlx::abi2::r0::string const&>(mysqlx::abi2::r0::SessionOption, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, mysqlx::abi2::r0::SessionOption::Enum&&, unsigned int&, mysqlx::abi2::r0::SessionOption::Enum&&, mysqlx::abi2::r0::string const&)':
/usr/include/mysql-cppconn-8/mysqlx/devapi/detail/settings.h:68: undefined reference to `mysqlx::abi2::r0::internal::Settings_detail<mysqlx::abi2::r0::internal::Settings_traits>::do_set(std::__cxx11::list<std::pair<int, mysqlx::abi2::r0::Value>, std::allocator<std::pair<int, mysqlx::abi2::r0::Value> > >&&)'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `void mysqlx::abi2::r0::internal::Settings_detail<mysqlx::abi2::r0::internal::Settings_traits>::set<true, mysqlx::abi2::r0::SessionOption, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(mysqlx::abi2::r0::SessionOption, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&)':
/usr/include/mysql-cppconn-8/mysqlx/devapi/detail/settings.h:68: undefined reference to `mysqlx::abi2::r0::internal::Settings_detail<mysqlx::abi2::r0::internal::Settings_traits>::do_set(std::__cxx11::list<std::pair<int, mysqlx::abi2::r0::Value>, std::allocator<std::pair<int, mysqlx::abi2::r0::Value> > >&&)'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `void mysqlx::abi2::r0::internal::Settings_detail<mysqlx::abi2::r0::internal::Settings_traits>::set<true, mysqlx::abi2::r0::SessionOption, mysqlx::abi2::r0::string const&>(mysqlx::abi2::r0::SessionOption, mysqlx::abi2::r0::string const&)':
/usr/include/mysql-cppconn-8/mysqlx/devapi/detail/settings.h:68: undefined reference to `mysqlx::abi2::r0::internal::Settings_detail<mysqlx::abi2::r0::internal::Settings_traits>::do_set(std::__cxx11::list<std::pair<int, mysqlx::abi2::r0::Value>, std::allocator<std::pair<int, mysqlx::abi2::r0::Value> > >&&)'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `void mysqlx::abi2::r0::internal::Args_processor<mysqlx::abi2::r0::internal::Row_detail, std::pair<mysqlx::abi2::r0::internal::Row_detail::Impl*, unsigned long>*>::process_args1<mysqlx::abi2::r0::Value, , (void*)0>(std::pair<mysqlx::abi2::r0::internal::Row_detail::Impl*, unsigned long>*, mysqlx::abi2::r0::Value)':
/usr/include/mysql-cppconn-8/mysqlx/devapi/common.h:862: undefined reference to `mysqlx::abi2::r0::internal::Row_detail::process_one(std::pair<mysqlx::abi2::r0::internal::Row_detail::Impl*, unsigned long>*, mysqlx::abi2::r0::Value const&)'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o): in function `mysqlx::abi2::r0::internal::Iterator<mysqlx::abi2::r0::internal::Schema_detail::Table_src, mysqlx::abi2::r0::Table, long, mysqlx::abi2::r0::Table*, mysqlx::abi2::r0::Table&>::Iterator(mysqlx::abi2::r0::internal::Schema_detail::Table_src&)':
/usr/include/mysql-cppconn-8/mysqlx/devapi/common.h:404: undefined reference to `mysqlx::abi2::r0::internal::Query_src::iterator_next()'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o):(.data.rel.ro._ZTCN6mysqlx4abi22r05ValueE0_NS1_6common5ValueE[_ZTVN6mysqlx4abi22r05ValueE]+0x18): undefined reference to `typeinfo for mysqlx::abi2::r0::common::Value'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o):(.data.rel.ro._ZTCN6mysqlx4abi22r05ValueE0_NS1_6common5ValueE[_ZTVN6mysqlx4abi22r05ValueE]+0x20): undefined reference to `mysqlx::abi2::r0::common::Value::print(std::ostream&) const'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o):(.data.rel.ro._ZTIN6mysqlx4abi22r08internal13Schema_detail8Name_srcE[_ZTIN6mysqlx4abi22r08internal13Schema_detail8Name_srcE]+0x10): undefined reference to `typeinfo for mysqlx::abi2::r0::internal::Query_src'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o):(.data.rel.ro._ZTIN6mysqlx4abi22r08internal17Row_result_detailINS1_7ColumnsEEE[_ZTIN6mysqlx4abi22r08internal17Row_result_detailINS1_7ColumnsEEE]+0x10): undefined reference to `typeinfo for mysqlx::abi2::r0::internal::Result_detail'
/usr/bin/ld: Database/MySQL/libMySQL.a(MySQL.cpp.o):(.data.rel.ro._ZTIN6mysqlx4abi22r05ValueE[_ZTIN6mysqlx4abi22r05ValueE]+0x28): undefined reference to `typeinfo for mysqlx::abi2::r0::common::Value'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

anybody knows what to do ?

Connector crashing on Windows (14 replies)

$
0
0
I am trying to install and use the c++ connector. I downloaded the DEBUG version of the connector. Linked the mysqlcppconn8.lib to my project, added the libcrypto-1_1.dll, libssl-1_1.dll and mysqlcppconn8-2-vs14.dll to my project directory. It compiles, seems to work, but crashes when opening a session. It looks like a bad library linked to the wrong dll or something (even though I did use both from the windows debug package).
I also added the preprocessor flag STATIC_CONCPP.

A simple: mysqlx::Session Sess(mysqlx://"root@127.0.0.1") crashes in the function:

Session(SessionSettings settings)
try
: Session_detail(settings)
{}
CATCH_AND_WRAP

with multiple memory errors like:
cdk::foundation::Generic_error at memory location 0x00AEE30C
[rethrow] at memory location 0x00000000.
mysqlx::abi2::r0::Error at memory location 0x00AEE9F0.


I use VS 2019 on windows. Downloaded the latest connector on DEBUG (I compile on DEBUG too).

Any idea?

MySQL sample test with C++ get build problem (no replies)

$
0
0
1. I use winddow 10 , vs2002 C++ ,MySQL community 8.0.32, Connector C++8.0.32
2. the vsc++ and mySQL seemed already linked successful, because I can query or insert record with vsc++ in mySQL with SQL session.

3.When I test the sample code in page 6 ,in "X DevAPI User Guide" , there is alway build problem happened :

#include <iostream>
#include <string>
#include <mysqlx/xdevapi.h>
using namespace std;
using namespace mysqlx;

int main()
{
Session mySession("localhost", 33060, "root", "passwd");

Schema db = mySession.getSchema("sakila");
Collection act = db.getCollection("actor"); // get table info
DocResult res = act.find("first_name like :param")//RowResult
.limit(1)
.bind("param", "L%").execute();
cout << res.fetchOne();
mySession.close();
}

above is my code try to select data from sample database "sakil",tabel "actor".

build stop in header file "xdevapi.h" ,said "abnormal unhandled" in
template<typename...T>
Session(T...options)
try
: Session(SessionSettings(options...))
{}CATCH_AND_WRAP


i don't know how to do , very appreciate for your help

Getting query results as strings (1 reply)

$
0
0
For a general SQL query, I want to return a map of columns and values converted to strings. However, while cout prints out the value of row[index], I cannot find a way to make sure it is a string rather than some other type. Code like the following fails because I can't convert that row element to a string. How do I go about this?
while ((row = res.fetchOne())) {
for (unsigned index = 0; index < res.getColumnCount(); index++) {
cout << columns[index].getColumnName() << ": "
<< row[index] << endl;
string s1 = columns[index].getColumnName();
string s2 = string(row[index]); //THIS FAILS
stpRow->insert({ s1, s2 }); //add to current map
}

Prepared queries in Connector C++ (1 reply)

$
0
0
I can't seem to find any documentation on how to used prepared queries using Connector C++ 8.0 library. How do I create a prepared query and how do I set the parameters before executing it?

mysql connector 8.0.32 c++ can't get results don't understand (no replies)

$
0
0
This code is connecting. I was able to create tables without any problems. Now I want to run queries and get the results. Tried a lot, not sure of the documentation. I looked at the .h files and couldn't figure it out.

After I execute:
res = stmt->execute("select * from user"); //<<<this must be wrong.
while (res->next()) {

}

what are the exact steps from the stmt->execute //or something else,
to reading each tuple in the results?

Thanks

sql::Driver* driver;
sql::Connection* con;
sql::Statement* stmt;
//sql::PreparedStatement* pstmt;
sql::ResultSet* res;

try
{
driver = get_driver_instance();
con = driver->connect(server, username, password);
}
catch (sql::SQLException e)
{
cout << "Could not connect to server. Error message: " << e.what() << endl;
system("pause");
exit(1);
}
cout << "connected to server" << endl;


stmt = con->createStatement();
stmt->execute("USE comp440");
stmt = con->createStatement();
res = stmt->execute("select * from user"); //<<<this must be wrong.
while (res->next()) {
// You can use either numeric offsets...
cout << "id = " << res->getInt(1); // getInt(1) returns the first column
// ... or column names for accessing results.
// The latter is recommended.
//cout << ", label = '" << res->getString("label") << "'" << endl;
}

variant.h error with MySQl c++ CONNECTOR (no replies)

$
0
0
I installed connector 8.0
when I try to run a c++ program in Visual Studio 22, I get:

Severity Code Description Project File Line Suppression State
Warning C26495 Variable 'sql::Variant::variant' is uninitialized. Always initialize a member variable (type.6). mysql_dev C:\Program Files\MySQL\Connector C++ 8.0\include\jdbc\cppconn\variant.h 298

Any help is appreciated.
Thanks,
Jim...

Shared memory protocol for windows clients (no replies)

$
0
0
Is anyone successfully using this?
I'm trying to connect but keep getting the 2046 error about client not being able to create the request event and can't connect to shared memory. I've tried all the normal tricks that are documented.
What could I be missing?

Error number: 2046; Symbol: CR_SHARED_MEMORY_CONNECT_SET_ERROR;

Message: Can't open shared memory; cannot send request event to server (%lu)

Use MysQL connector client 6.1.11 with MySQL 8.0.32 (1 reply)

$
0
0
Use MysQL connector client 6.1.11 with MySQL 8.0.32. SSL connections to MySQL 8 from 6.1.11 'c' connector. How do I set the TLS version ? I am getting "SSL connection error: TLS version is invalid" even though both server and client are using TLSv1.2

can build connector app: symbols(s) not found for architecture arm64 (no replies)

$
0
0
Hi guys,

beginner here, I'm having trouble with my first mysql project. I've downloaded the c++ connector for arm64 and am trying to use it with X DevAPI in my program. But, when building I'm running into the following error message:

FAILED: mysql_test
: && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -g -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -mmacosx-version-min=13.0 -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/mysql_test.dir/main.cpp.o -o mysql_test && :
Undefined symbols for architecture arm64:
"mysqlx::abi2::r0::common::Settings_impl::Data::init_connection_attr()", referenced from:
mysqlx::abi2::r0::common::Settings_impl::Data::Data() in main.cpp.o
"mysqlx::abi2::r0::string::Impl::from_utf8(mysqlx::abi2::r0::string&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
mysqlx::abi2::r0::string::traits<char>::from_str(mysqlx::abi2::r0::string&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in main.cpp.o
"mysqlx::abi2::r0::internal::Session_detail::close()", referenced from:
mysqlx::abi2::r0::internal::Session_detail::~Session_detail() in main.cpp.o
"mysqlx::abi2::r0::internal::Session_detail::Name_src::Name_src(mysqlx::abi2::r0::Session const&, mysqlx::abi2::r0::string const&)", referenced from:
mysqlx::abi2::r0::Schema::existsInDatabase() const in main.cpp.o
"mysqlx::abi2::r0::internal::Session_detail::Session_detail(mysqlx::abi2::r0::common::Settings_impl&)", referenced from:
mysqlx::abi2::r0::Session::Session(mysqlx::abi2::r0::SessionSettings) in main.cpp.o
"mysqlx::abi2::r0::internal::Settings_detail<mysqlx::abi2::r0::internal::Settings_traits>::do_set(std::__1::list<std::__1::pair<int, mysqlx::abi2::r0::Value>, std::__1::allocator<std::__1::pair<int, mysqlx::abi2::r0::Value> > >&&)", referenced from:
void mysqlx::abi2::r0::internal::Settings_detail<mysqlx::abi2::r0::internal::Settings_traits>::set<true, mysqlx::abi2::r0::SessionOption::Enum, char const*&, mysqlx::abi2::r0::SessionOption::Enum&, int&, mysqlx::abi2::r0::SessionOption::Enum&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, mysqlx::abi2::r0::SessionOption::Enum&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&>(mysqlx::abi2::r0::SessionOption::Enum, char const*&, mysqlx::abi2::r0::SessionOption::Enum&, int&, mysqlx::abi2::r0::SessionOption::Enum&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, mysqlx::abi2::r0::SessionOption::Enum&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) in main.cpp.o
"mysqlx::abi2::r0::internal::Query_src::iterator_next()", referenced from:
mysqlx::abi2::r0::Schema::existsInDatabase() const in main.cpp.o
"mysqlx::abi2::r0::internal::Query_src::~Query_src()", referenced from:
mysqlx::abi2::r0::internal::Session_detail::Name_src::~Name_src() in main.cpp.o
"mysqlx::abi2::r0::common::Value::print(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const", referenced from:
mysqlx::abi2::r0::Value::print(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const in main.cpp.o
construction vtable for mysqlx::abi2::r0::common::Value-in-mysqlx::abi2::r0::Value in main.cpp.o
"typeinfo for mysqlx::abi2::r0::common::Value", referenced from:
construction vtable for mysqlx::abi2::r0::common::Value-in-mysqlx::abi2::r0::Value in main.cpp.o
typeinfo for mysqlx::abi2::r0::Value in main.cpp.o
"VTT for mysqlx::abi2::r0::common::Value", referenced from:
mysqlx::abi2::r0::common::Value::~Value() in main.cpp.o
"vtable for mysqlx::abi2::r0::DbDoc", referenced from:
mysqlx::abi2::r0::DbDoc::~DbDoc() in main.cpp.o
mysqlx::abi2::r0::DbDoc::DbDoc() in main.cpp.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.


Thank you for any responses:D

Need help to put the static libs working in c nor in c++ (no replies)

$
0
0
hi, i am trying to put the mysql librarys has statik in codeblocks, but i cant.
in c ++ give me
undefined refenred to check(std::__cxxll::basic_string<...>...)
undefined refenred to sql::mysql::_get_driver:instance:by_name()

in c
i can do the dinamic but can't in stack it gives alot of errores starting with fprinf... makes no sense


please help

Constructing a MySQL Connector/C++ class object after one is destroyed (2 replies)

$
0
0
Using MySQL Connector/C++ 8.0 I define a Database class and construct an object of that class to connect to the database. That works fine. If that object is destroyed and I try to construct another one, then it fails.

Here's the class:

class Database {
private:
std::unique_ptr<mysqlx::Session> _session;
std::unique_ptr<mysqlx::Table> _table;
std::unique_ptr<mysqlx::Schema> _schema;
public:
Database( std::string host,
int port,
std::string user,
std::string pass,
std::string schema,
std::string table ) {
_session = std::make_unique<mysqlx::Session> ( mysqlx::SessionOption::HOST, host,
mysqlx::SessionOption::PORT, port,
mysqlx::SessionOption::USER, user,
mysqlx::SessionOption::PWD, pass );

_schema = std::make_unique<mysqlx::Schema>( *_session, schema );
_table = std::make_unique<mysqlx::Table>( _schema->getTable( table ) );

void write( std::map<std::string, std::string> data ); // details not pertinent here

// close might be overkill? shouldn't things get cleaned up when
// the object goes out of scope and is deconstructed?
//
inline void close() { _session->close(); _session.reset(); _table.reset(); _schema.reset(); }
}
}

I can instantiate a Database object in a thread (only one such "database" thread can ever be started at a time, so there is never any risk of contention), such as:

void SomeClass::dothread_db( host,port,... etc.. ) {
try {
Database::Database database(host,port,user,pass,schema,table);
while (condition ) {
database.write(...);
// things can change the condition
}

database.close(); // is this even needed?

} catch etc..

return;
}

I can spawn dothread_db once, and it connects to the database and writes to it all day long, but if the conditions are met such that it completes, and then I try to spawn another one, I will get one of two possible errors:

CDK Error: OpenSSL: error:00000000:lib(0):func(0):reason(0)

or

CDK Error: Bad file descriptor (generic:9)

when it tries to construct the Database object. I see no messages in /var/log/mysql/ logs.

in eclipse mysql connector/c++ not working on M1 Macbook air (no replies)

$
0
0
Using Eclipse, I am trying to create a simple example of how to query a mysql database using the mysql connector/c++

I keep getting this error Description Resource Path Location Type exception specification of overriding function is more lax than base version mysqlCppProj line 91, external location: /Users/me/c++Libraries/mysql-connector-c++-8.2.0-macos13-arm64/include/jdbc/cppconn/exception.h C/C++ Problem

I am using Eclipse IDE for C/C++ Developers (includes Incubating components)

Version: 2023-12 (4.30.0) Build id: 20231201-2043

Any solution I find is dated from 2012 or there abouts.
Viewing all 527 articles
Browse latest View live


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