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

connector 8 Session exception (17 replies)

$
0
0
I have setup the very basic program as follow in Visual Studio 2017. x64 compiles/links fine. The local debugger immediately produces a memory exception when trying to open a session. I tried this on 2 different win 10 machines - I am probably missing something very basic. Any further debugging ideas would be appreciated! Thans

#include <mysqlx/xdevapi.h>

using namespace mysqlx;

int main()
{
Session sess("localhost", 33060, "user", "password");
}

the exception happens at

template<typename...T>
Session(T...options)
try
: Session(SessionSettings(options...))
{}CATCH_AND_WRAP

Unhandled exception at 0x00007FFF88F1A388 in mysqltest.exe: Microsoft C++ exception: mysqlx::Error at memory location 0x00000050AA2FFBD8. occurred

Legacy C issue (1 reply)

$
0
0
I am trying to use the newest connector (8.0.19) to build legacy c programs. This is the CPP connector but documentation indicates that it can also be used to run legacy c programs although there is little or no documentation on how to do this.

What I've tried is to create a new c project in Xcode 11; add the header search path for the mysql connector includes (/usr/local/mysql-connector-c++-8.0.19/include) and then add the include reference:

#include <mysql/jdbc.h>

into my (empty) program. However build fails with error that <map> cannot be resolved. It's referenced in the included file ../jdbc/cppcon/connection.h

Is this supposed to work? If so, what are the appropriate includes.

thanks for any response

NOTE: I also filed a bug for this

Site5 & Schema (no replies)

$
0
0
Hello,
I am hoping someone can help me.
As most may know site5 is one of the popular web hosting sites.
I am trying to understand what "Schema" would refer to in their setup.
Such as would schema be the cluster of databases or a specific databse?
The same with DB is this the cluster or the specific one within the clustor?

Static linking to Connector/C++ on linux giving errors (3 replies)

$
0
0
I'm trying to link the static connector library using the following makefile:

MYSQL_CONCPP_DIR = /usr/include/mysql-cppconn-8
CPPFLAGS = -DSTATIC_CONCPP -I $(MYSQL_CONCPP_DIR)/include
LDLIBS = $(MYSQL_CONCPP_DIR)/lib64/libmysqlcppconn8-static.a -lssl -lcrypto -lpthread
CXXFLAGS = -std=c++11
main : main.cpp

Main.cpp is as simple as this:

#include <mysqlx/xdevapi.h>
int main() { return 0; }

I get a few errors. The first one is:
/usr/include/mysql-cppconn-8/lib64/libmysqlcppconn8-static.a(libcdk_foundation_socket_detail.cc.o): In function `cdk::foundation::connection::detail::srv_list(std::string const&)':
socket_detail.cc:(.text+0x11c2): undefined reference to `__res_nsearch'
socket_detail.cc:(.text+0x11f7): undefined reference to `ns_initparse'
socket_detail.cc:(.text+0x133d): undefined reference to `ns_parserr'
socket_detail.cc:(.text+0x13b0): undefined reference to `__dn_expand'

What am I doing wrong here?

C++ mysql connection problem (no replies)

$
0
0
I've centos7.5 and codeblocks 17 in VM. i am trying to build small project that needs to connect to mysql connection with c++. but having this error :-

||=== Build: Release in cbs (compiler: GNU GCC Compiler) ===|
/usr/include/mysql/mysql/psi/psi.h|40|error: #error "You must include my_global.h in the code for the build to be correct."|
/usr/include/mysql/mysql/psi/psi.h|40|error: #error "You must include my_global.h in the code for the build to be correct."|
/usr/include/c++/4.8.2/bits/stl_algobase.h|239|error: macro "min" passed 3 arguments, but takes just 2|
/usr/include/c++/4.8.2/bits/stl_algobase.h|260|error: macro "max" passed 3 arguments, but takes just 2|
/usr/include/mysql/mysql/psi/mysql_thread.h||In function ‘int inline_mysql_cond_wait(mysql_cond_t*, mysql_mutex_t*, const char*, uint)’:|
/usr/include/mysql/mysql/psi/mysql_thread.h|1151|error: ‘my_cond_wait’ was not declared in this scope|
/usr/include/mysql/mysql/psi/mysql_thread.h|1162|error: ‘my_cond_wait’ was not declared in this scope|
/usr/include/mysql/mysql/psi/mysql_thread.h||In function ‘int inline_mysql_cond_timedwait(mysql_cond_t*, mysql_mutex_t*, const timespec*, const char*, uint)’:|
/usr/include/mysql/mysql/psi/mysql_thread.h|1188|error: ‘my_cond_timedwait’ was not declared in this scope|
/usr/include/mysql/mysql/psi/mysql_thread.h|1199|error: ‘my_cond_timedwait’ was not declared in this scope|
/usr/include/c++/4.8.2/bits/stl_algobase.h|193|error: expected unqualified-id before ‘const’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|193|error: expected ‘)’ before ‘const’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|193|error: expected ‘)’ before ‘const’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|193|error: expected initializer before ‘const’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|216|error: expected unqualified-id before ‘const’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|216|error: expected ‘)’ before ‘const’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|216|error: expected ‘)’ before ‘const’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|216|error: expected initializer before ‘const’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|239|error: ‘std::min’ declared as an ‘inline’ variable|
/usr/include/c++/4.8.2/bits/stl_algobase.h|239|error: template declaration of ‘const _Tp& std::min’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|242|error: expected primary-expression before ‘if’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|242|error: expected ‘}’ before ‘if’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|244|error: expected unqualified-id before ‘return’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|260|error: ‘max’ declared as an ‘inline’ variable|
/usr/include/c++/4.8.2/bits/stl_algobase.h|260|error: template declaration of ‘const _Tp& max’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|263|error: expected primary-expression before ‘if’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|263|error: expected ‘}’ before ‘if’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|265|error: expected unqualified-id before ‘return’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|266|error: expected declaration before ‘}’ token|
/usr/include/mysql/mysql/psi/psi.h|40|error: #error "You must include my_global.h in the code for the build to be correct."|
/usr/include/c++/4.8.2/bits/stl_algobase.h|239|error: macro "min" passed 3 arguments, but takes just 2|
/usr/include/c++/4.8.2/bits/stl_algobase.h|260|error: macro "max" passed 3 arguments, but takes just 2|
/usr/include/mysql/mysql/psi/mysql_thread.h||In function ‘int inline_mysql_cond_wait(mysql_cond_t*, mysql_mutex_t*, const char*, uint)’:|
/usr/include/mysql/mysql/psi/mysql_thread.h|1151|error: ‘my_cond_wait’ was not declared in this scope|
/usr/include/mysql/mysql/psi/mysql_thread.h|1162|error: ‘my_cond_wait’ was not declared in this scope|
/usr/include/mysql/mysql/psi/mysql_thread.h||In function ‘int inline_mysql_cond_timedwait(mysql_cond_t*, mysql_mutex_t*, const timespec*, const char*, uint)’:|
/usr/include/mysql/mysql/psi/mysql_thread.h|1188|error: ‘my_cond_timedwait’ was not declared in this scope|
/usr/include/mysql/mysql/psi/mysql_thread.h|1199|error: ‘my_cond_timedwait’ was not declared in this scope|
/usr/include/c++/4.8.2/bits/stl_algobase.h|193|error: expected unqualified-id before ‘const’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|193|error: expected ‘)’ before ‘const’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|193|error: expected ‘)’ before ‘const’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|193|error: expected initializer before ‘const’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|216|error: expected unqualified-id before ‘const’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|216|error: expected ‘)’ before ‘const’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|216|error: expected ‘)’ before ‘const’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|216|error: expected initializer before ‘const’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|239|error: ‘std::min’ declared as an ‘inline’ variable|
/usr/include/c++/4.8.2/bits/stl_algobase.h|239|error: template declaration of ‘const _Tp& std::min’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|242|error: expected primary-expression before ‘if’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|242|error: expected ‘}’ before ‘if’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|244|error: expected unqualified-id before ‘return’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|260|error: ‘max’ declared as an ‘inline’ variable|
/usr/include/c++/4.8.2/bits/stl_algobase.h|260|error: template declaration of ‘const _Tp& max’|
/usr/include/c++/4.8.2/bits/stl_algobase.h|263|error: expected primary-expression before ‘if’|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build failed: 50 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

I already included "mysql/my_global.h" but even this problem arised.

std::iterator deprecated in C++17. (no replies)

$
0
0
I want to use C++17 in my project but the MySQL Connector uses deprecated std::iterator in the headers which gives an error in Visual Studio as it is deprecated. So, will std::iterator get removed from the connector anytime soon?

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

Boost library (should be) deprecated (no replies)

$
0
0
In the process of switching over to a 32-bit C++ connector library, I had occasion to revisit the build procedure. The connector source needs to include template classes from the Boost library, which consists of over 60,000 files that collectively occupy more than half a gig of disk space. The boost library will not compile with version 12 of the Microsoft compiler, which is the one I use for my million-line app.

Gentlemen, this is the aftermath of a bad design choice, says 50 years of experience on large and small software projects. To put it another way, it is a conspicuous example of what might be called the tail-wagging-the-dog syndrome, wherein developers rely on gigantic pieces of infrastructure that happen to be lying about on their machines.

The purpose of the connector library is to bridge between an app and the MySQL engine. It ought to be simple, and the source code ought to be usable with any reasonably robust set of build tools. Someone has gone badly astray by relying on a third-party library instead of crafting a self-contained solution.

Is there a sample code using "MySQL 8.0: Connector / C ++"? (2 replies)

$
0
0
I'm sorry for the followers
Is there a sample code using "MySQL 8.0: Connector / C ++"?

Development environment
Visualstudio2019enterprise
OS: windows server2019

Access denied to database even when privileges granted (3 replies)

$
0
0
Hi, I am using MySQL C++ connector 8.0 and while I connect to the database successful my program crashed saying access denied for user to the database. I have the user INSERT UPDATE DELETE AND SELECT privileges. At the time of the crash the program was inserting into the database. However I do a check to see if the table is locked before doing anything by running the query SHOW OPEN TABLES. But I believe I don't need superuser permissions for that? Or am I wrong? I logged into the mysql shell with the same user and can verify that I can insert into the database from there so I'm starting to think it could be the SHOW OPEN TABLES?

Thanks,
Eddy

Warnings from IntelliSense. MYSQL C++/Connector Setup (no replies)

$
0
0
I installed MYSQL and C++/Connector yesterday. After I added all libs and includes, it worked.

But I am left with these warnings from IntelliSense:


1.Dereferencing NULL pointer 'sess'.

2.The enum type 'mysqlx::abi2::r0::ClientOption::Enum' is unscoped. Prefer 'enum class' over 'enum' (Enum.3). (I got 7 more enum warnings like this one)

3.This kind of function may not throw. Declare it 'noexcept' (f.6). (7 more like this one as well)

4.Variable 'mysqlx::abi2::r0::common::Value::m_val' is uninitialized. Always initialize a member variable (type.6).


Should I try to correct these warnings on my own or continue without concern and wait for future updates instead (lib / h files)

mysql-connector-cpp-8.0.20 CDK Error: Failed string conversion (1 reply)

$
0
0
I have a problem reading the utf-8 string from the database.
I found out that the problem is with the symbol U+FF08

Code example:
auto res = session.sql(u8"SELECT '(' as zh").execute();
try {
res.fetchOne()[0];
}
catch (std::exception ex) {
std::cout << ex.what() << std::endl;
}

Output:
CDK Error: Failed string conversion

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

mysql connector c++ 8.0.20 (3 replies)

$
0
0
Hi, when i use c++ api connect to mysql server, it is conencted time out!!

computer: win7 sp1 vs2019 professional

code :
std::string user = "test";
std::string passwd = "123";
std::string ip = "localhost";

Session sess(ip, 3306, user, passwd);
Schema db = sess.getSchema("test");

i don't know what happend

Connections errors to server (no replies)

$
0
0
Hi everybody,
i had tried to find existing topic about my problems but i haven't found.
So my architecture is:

- Raspberry like computer, ARM
- OS linux Raspian
- C++ the coding
- Mysql library mysql Ver 14.14 Distrib 5.5.31, for debian-linux-gnu (armv7l) using readline 6.2

i had add mysql connection in my software, it's work good for a limited time but late i have errors like:
- 2006 HY000 MySQL server has gone away
-2013 HY000 Lost connection to MySQL server at 'reading authorization packet', system error:
-2003 HY000 Can't connect to MySQL server on
-2013 HY000 Lost connection to MySQL server during query

Server is remote, it's on internet platform, and i'm sure that the internet connection is good.
After these errors the simple connection become difficulty, indeed if i restart my application all work good again until come back the errors.


It's strange and for now i haven't found solutions.

Somebody know about this behavior?

Thanks advance.

Mysql connector c++ 8.0. How to do INSERT IGNORE? (no replies)

$
0
0
I want to do the equivalent of INSERT IGNORE to a table with a UNIQUE constraint. I can't find a way to do this with the C++ connector, so I've fallen back to capturing the Error and checking to see whether its string begins "CDK Error: Duplicate ". Is there a better way?

Performance of X DevApi very slow compared to legacy JDBC (no replies)

$
0
0
Hello,

we wanted to rewrite our code which previously used the legacy JDBC API and migrate that to the X DevApi. However, we faced a problem when we tried to compare the performance of the Legacy JDBC API with the X DevAPI.
Attached is the very basic version that just selects a couple of thousand records from a MySQL DB.
The for-loop which creates and executes the select statement runs 10-20x slower using the X DevAPI.
Are we missing something here? What could produce such a significant speed difference between these two versions?

Legacy Code
    auto const lDataBaseHostName = gTechnicalConfiguration.GetSetting(utl::Constants::cDataBaseURIName);
    auto const lDataBaseUser = gTechnicalConfiguration.GetSetting(utl::Constants::cDataBaseUserName);
    auto const lDataBasePassword = gTechnicalConfiguration.GetSetting(utl::Constants::cDataBasePasswordName);
    auto const lDataBaseSchema = gTechnicalConfiguration.GetSetting(utl::Constants::cDataBaseSchemaName);
    auto* lDriver = sql::mysql::get_driver_instance();

    auto const lDataBaseConnection = lDriver->connect(lDataBaseHostName.c_str(), lDataBaseUser.c_str(), lDataBasePassword.c_str());

    auto connection = std::shared_ptr<sql::Connection>(lDataBaseConnection);
    if (!connection->isValid()) {
      throw exc::LogicErrorException("Cannot open DB connection");
    }
    connection->setSchema(lDataBaseSchema.c_str());

    for (auto _ : state) {
      std::shared_ptr<sql::Statement> stmt(connection->createStatement());
      std::shared_ptr<sql::ResultSet> res(stmt->executeQuery("SELECT * FROM product"));
      while (res->next()) { }
    }

X DevApi Code
    auto const                      lDataBaseHost = technicalConfiguration.GetSetting(utl::Constants::cDataBaseHost);
    auto const                      lDataBasePort = technicalConfiguration.GetSetting(utl::Constants::cDataBasePort);
    auto const                      lDataBaseUser = technicalConfiguration.GetSetting(utl::Constants::cDataBaseUserName);
    auto const                      lDataBasePassword = technicalConfiguration.GetSetting(utl::Constants::cDataBasePasswordName);
    auto const                      lDataBaseSchema = technicalConfiguration.GetSetting(utl::Constants::cDataBaseSchemaName);
    std::shared_ptr<mysqlx::Client> client = nullptr;
    client = std::make_shared<mysqlx::Client>(
      mysqlx::SessionOption::USER,          lDataBaseUser,
      mysqlx::SessionOption::PWD,           lDataBasePassword,
      mysqlx::SessionOption::HOST,          lDataBaseHost,
      mysqlx::SessionOption::PORT,          std::stoi(lDataBasePort),
      mysqlx::SessionOption::DB,            lDataBaseSchema,
      mysqlx::SessionOption::SSL_MODE,      mysqlx::SSLMode::REQUIRED,
      // Enforced to verify server certificate
      mysqlx::ClientOption::POOLING,        true,
      mysqlx::ClientOption::POOL_MAX_SIZE,  25
      );

    auto session = client->getSession();
    for (auto _ : state) {      
      mysqlx::SqlStatement statement = session.sql("SELECT * FROM product");
      auto                 retValue  = statement.execute();
      for (auto lRow : retValue) {
        
      }
    }

Lost connection to MySQL server during query (no replies)

$
0
0
Hi all,
Recently I trying to using connector cpp 1.1.7 to access mysql server(both os is Debian stretch),but encounter "Lost connection to MySQL server during query" problem.It happens when i using transaction, my transaction code looks like :
bool ExecTransaction(const std::vector<std::string>& sqls) {
sql::Statement* statement = nullptr;
sql::Connection* conn = nullptr;
conn = GetConnection();
// for simple, delete code is not written here

try {
conn->setSchema(schema);
statement = conn->createStatement();
conn->setAutoCommit(false);
for (auto& sql : sqls) {
statement->execute(sql);
}
conn->commit();
return true;
} catch (sql::SQLException& e) {
goto rollback;
} catch (std::runtime_error& e) {
goto rollback;
}

rollback:
try {
conn->rollback();
return false;
} catch (sql::SQLException& e) {
return false;
} catch (std::runtime_error& e) {
return false;
}
}

Is there any problem here?Why this problem won't happen if i don't use transaction.

Connector/C++ (no replies)

$
0
0
When will Connector/C++ support async execution?

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

Viewing all 527 articles
Browse latest View live


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