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

how to cast fields to c++ data types (no replies)

$
0
0
I'm trying to do the most simplest of things, convert a field from a fetched row into my C++ double variable.

Connector 1.1 used a simple 'getDouble', i.e.
double aval = res->getDouble("cash_value"); //res is Resultset, cash_value a field

I can't seem to find any way to perform this using the new (i.e. 8.0) connector.

I've no problem running the select, accessing the rows in the ResultSet.

Thanks in advance for any help on this.


Embarrassingly simple question, shameful that no simple documentation exists on this.

data change listener (6 replies)

$
0
0
I have a RDS account in amazon and i use the c++ mysql connector for querries from my raspberry pi.

how can I receive kind of signal when a data has been changed?

I can use a thread which will iterate all the data base and checks for changes but I think is wasfull.

Any help?

Failed to connect to mysql server with c++ connector on Fedora25 (no replies)

$
0
0
Hello,

I've created a c++ application in order to connect to mysql server in local, on linux system (fedora 25).

I've downloaded this version off the connector: mysql-connector-c++-1.1.11-linux-glibc2.12-x86-64bit.tar.gz

When I tried to connect with my application, I have this error message:
FATAL [17919] [MySQLWrapper::Connect@48] SQLException connecting to tcp://127.0.0.1:3306, root:password : Access denied for user 'root'@'localhost' (using password: NO)

The server is running and I succeed to connect with: "mysql -u root -p" or with the workbench.

It seems that there is a problem with the connector, if you can help me I will really appreciate it. (and the firewall is off)

Could not find dynamic "mysqlclient_r mysqlclient" in MYSQL_LIB_DIR (1 reply)

$
0
0
Hello! I'm trying to build Connector/C++ on CentOS 7. When I run "cmake ." I get the following output:

-- Boost version: 1.65.1
-- BOOST_INCLUDE_DIRS=/usr/local/boost_1_65_1
-- You will link dynamically to the MySQL client library (set with -DMYSQLCLIENT_STATIC_LINKING=<bool>)
-- Searching for dynamic libraries with the base name(s) "mysqlclient_r mysqlclient"
-- mysql_config was found /bin/mysql_config
CMake Error at FindMySQL.cmake:406 (message):
Could not find dynamic "mysqlclient_r mysqlclient" in MYSQL_LIB_DIR
"/usr/lib64"
Call Stack (most recent call first):
FindMySQL.cmake:649 (_check_lib_search_error)
CMakeLists.txt:252 (INCLUDE)

Even though I have the following files inside /usr/lib64:
./libmysqlclient.so.15
./libmysqlclient.so.15.0.0
./libmysqlclient.so.16
./libmysqlclient.so.16.0.0
./libmysqlclient.so.18
./libmysqlclient.so.18.0.0
./libmysqlclient_r.so.15
./libmysqlclient_r.so.15.0.0
./libmysqlclient_r.so.16
./libmysqlclient_r.so.16.0.0

Anything I can do? Thanks!

Connector/C++ Compilation Errors using Visual Studio 2015 (1 reply)

$
0
0
I downloaded the latest Connector/C++ from gitHub (ver: 1.1.9) and ran CMake using the following command:

%> "C:\Program Files (x86)\CMake-3.8.2\bin\cmake.exe" -G"Visual Studio 14 2015" -DBOOST_ROOT=C:\AppLibs\boost_1_65_1 -DMYSQL_CONFIG_EXECUTABLE=mysql.exe -DMYSQL_DIR="C:\Program Files (x86)\MySQL\MySQL Server 5.1" -DMYSQL_INCLUDE_DIR="C:\Program Files (x86)\MySQL\MySQL Server 5.1\include" -DMYSQL_LIB_DIR="C:\Program Files (x86)\MySQL\MySQL Server 5.1\lib\opt"

After generating the VS 2015 Solution (MYSQLCPPCONN.sln), I opened Visual Studio 2015, and opened the built Solution. When I tried to run a DEBUG build, I keep receiving these compilation errors:

-----------------------------------------
---------- Compiler Errors --------------
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\cmath(725): error C2039: 'isnan': is not a member of '`global namespace''
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\cmath(725): error C2873: 'isnan': symbol cannot be used in a using-declaration

-----------------------------------------

I originally tried compiling the Connector/C++ in Visual Studio 2013, using the correct CMake generator, but received these errors. This prompted me to upgrade to Visual Studio 2015.

Does anyone know how to fixed these problems? Is there a fix for this?

No se puede encontrar el tipo o el nombre de espacio de nombres 'MySql' (¿falta una directiva using o una referencia de ensamblado?) (no replies)

$
0
0
Hola! nesecito ayuda, estoy usando una conexion a wampserver y programando en visual studio 2010. El detalle es que me arroja ese problema y no puedo conectarme a la base de datos. Como arreglo ese problema?

What kind of license do i need for public free application using MySql Connector/C++ ? (2 replies)

$
0
0
Hi,

i made an application that uses MySql Connector/C++ to connect to mysql servers
without modifying it but using it as static lib inside this app.

This application is free as an application and free to all its services.
What do i need to do with license about using MySql Connector/C++ if i want my
application to go public ?

Do i have to use some license inside each copy of my application or do i need something more than that and what am i looking for ?

Thanks in advance

how to configure or rebuild php 5.6 to use MySQL client server library (libmysqlclient) (no replies)

$
0
0
please help me in windows how to configure php 5.6 or 7 to use MySQL client server library (libmysqlclient) instead of MySQL native driver (mysqlnd).

Versions mapping (1 reply)

$
0
0
Hi,


I'm using the community server 5.7
I'm using the C++ connector


Ques #1. which connector version should I use?

Unfortunately, there is no mapping table between the server version and the connector version to be used?

the question is valid for all other languages - Python, Java, PHP - as well


Ques #2. Switching to Server 8.0 requires an upgrade of the connector?


Thanks

MySQL Connector 8.0 and Visual Studio 17 (no replies)

$
0
0
Hello,
I am using Visual Studio 17. Is MySQL connector 8.0 available for that compiler? I see alot of references to 2015 in the "Build from Source" documentation. Also CMAKE -G does not seem to have VS 2017 support.

thanks

ERROR CONNECTION | CDK Error: Connection refused (generic:111) (no replies)

$
0
0
Hi !
I'm sorry for my english, I'm french. I will try to be clear.

I have a problem with MySQL Connector/C++ 8.0.

When I try to connect my program to the session that I created for, my connection is refused with the error : CDK Error: Connection refused (generic:111)

I am working on Ubuntu 18.04 LTS.

My code is short, I only want to try a connection :

// Standard library
#include <iostream>

// MySQL Library
#include <mysqlx/xdevapi.h>

using namespace std;
using namespace mysqlx;

// Main entry point
int main(int argc, char ** argv)
{
  Session xoroseds_session("localhost", 33060, "xoroseds_api", "****");
  Schema db(xoroseds_session, "XOROSEDS_TEST");
  
  return 0;
}

I got the port from MySQL "itself" so I know that the right port is 3306 but when I try it, my error is CDK Error: unexpected message
and by the way a core dumped error... So I use 33060.

Thanks

C++17 and version 1.1 of connector (1 reply)

$
0
0
I need to build with C++17 but have encountered this error on Ubuntu 16.04:

/usr/local/include/cppconn/exception.h: At global scope:
/usr/local/include/cppconn/exception.h:98:2: error: ISO C++17 does not allow dynamic exception specifications
MEMORY_ALLOC_OPERATORS(SQLException)
^~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/cppconn/exception.h:98:2: error: ISO C++17 does not allow dynamic exception specifications
MEMORY_ALLOC_OPERATORS(SQLException)

I'm running on 2 systems: MacOS and Ubuntu 16.04. For Mac OS, I can build fine (using latest Xcode 10.1). For Ubuntu, I'm running gcc 8. Previously I was using C++11 with gcc 5.4, so things were working fine. But today I updated to gcc 8 and encountered these problems.

On the download page, MacOS allows me to use 1.1.11. However for Ubuntu, only 18.04 has 1.1.11. Moreover github looks behind by 2 years. (for 1.1).

Is there a way for me to get either 16.04 or can github actually be updated to reflect the latest so we can at least build it ourselves? Or can I use the 18.04 version of the SDK on 16.04?

SSLEAY32.DLL (no replies)

$
0
0
Trying to use the sample connector code to connect to a MySQL db and table using C++. Compiles fine, links fine, but on execution I get SSLEAY32.dll not found. The MySQL db in question has the SSL flag off! The server is WAMPSERVER. Tried copying the DLL into the apache bin and exe bin, but doesn't do any good. Any help appreciated!

Undefined symbols for architecture x86_64: "_get_driver_instance" (1 reply)

Unity Android MySQL connection function failing: Index was outside the bounds of the array. (1 reply)

$
0
0
I have a class to handle all of the database interactions between the client and database (MySQL) (I know and understand that I shouldn't allow direct access to a database)

public T getDatabaseValue<T>(string value, string query)
{
try
{
connection = new MySqlConnection(connectionString);
connection.Open();
command = new MySqlCommand(query, connection);
MySqlDataReader reader = command.ExecuteReader();
if (reader.Read())
{
return (T)reader[value];
}
else
return default(T);
}
catch (MySqlException SQLex)
{
Debug.Log("Database get failed (SQL Exception), query: " + query);
Debug.Log("Exception Message: " + SQLex.Message);
return default(T);
}
catch (System.Exception ex)
{
Debug.Log("Database get failed (System Exception), query: " + query);
Debug.Log("Exception Message: " + ex.Message);
return default(T);
}
}
This works flawlessly in the editor. When building and running on Android I get this error message via Monitor:

01-01 15:21:14.141: I/Unity(23761): (Filename: ./Runtime/Export/Debug.bindings.h Line: 43)
01-01 15:21:14.829: I/Unity(23761): Database get failed (System Exception), query: SELECT MAX(DT_Stamp) FROM tbl_Store;
01-01 15:21:14.829: I/Unity(23761):
01-01 15:21:14.829: I/Unity(23761): (Filename: ./Runtime/Export/Debug.bindings.h Line: 43)
01-01 15:21:14.829: I/Unity(23761): Exception Message: Index was outside the bounds of the array.
I'm not using an array to store the contents of the reader, here is the line that calls this example (it happens for all database interactions, not just this one, and not just this database querying function):

DateTime DB_Date = getDatabaseValue<DateTime>("MAX(DT_Stamp)", "SELECT MAX(DT_Stamp) FROM tbl_Store;");
Here's the contents of tbl_Store:

(Item_ID (int)), (Item_Name (varchar)), (Item_Price (float)), (In_Use (bit)), (DT_Stamp (datetime))

4 Hero Upgrade #1 100 1 2018-12-11 09:53:14
5 Hero Upgrade #2 300 1 2018-12-11 09:53:14
6 Hero Upgrade #3 700 1 2018-12-11 09:53:14

I'm probably missing something really simple here but any help would be greatly appreciated!

ResultSet->getString() code (no replies)

$
0
0
mysql> show variables like '%char%';
+--------------------------+---------------------------------------+
| Variable_name | Value |
+--------------------------+---------------------------------------+
| character_set_client | gbk |
| character_set_connection | gbk |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | gbk |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | D:\YJF\YJFMySQL\mysql\share\charsets\ |
+--------------------------+---------------------------------------+
8 rows in set (0.00 sec)

mysql> use ygx;
Database changed
mysql> show create database ygx;
+----------+--------------------------------------------------------------+
| Database | Create Database |
+----------+--------------------------------------------------------------+
| ygx | CREATE DATABASE `ygx` /*!40100 DEFAULT CHARACTER SET utf8 */ |
+----------+--------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> show create table test;
+-------+-----------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+-----------------------------------------------------------------------------------------------------------------------------+
| test | CREATE TABLE `test` (
`姓名` varchar(20) DEFAULT NULL,
`年龄` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+-------+-----------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> use ygx;
Database changed
mysql> select * from test;
+------+------+
| 姓名 | 年龄 |
+------+------+
| 张三 | 20 |
+------+------+
1 row in set (0.00 sec)




int main()
{
sql::mysql::MySQL_Driver *driver = NULL;
sql::Connection *conn = NULL;
sql::Statement *stmt = NULL;
sql::ResultSet *res = NULL;
try
{
driver = sql::mysql::get_mysql_driver_instance();
conn = driver->connect("tcp://localhost:3306/ygx", "root", "123456");
cout << "连接成功!" << endl;
}
catch (const std::exception&)
{
cout << "连接失败!" << endl;
goto END;
}
try
{
stmt = conn->createStatement();
stmt->execute("set character set gbk");
/* stmt->execute("set character_set_results= gbk");
stmt->execute("set character_set_client=gbk");
stmt->execute("set character_set_connection= gbk");
*/ res = stmt->executeQuery("select * from test where 姓名='张三'");

}
catch (const std::exception&)
{
cout << "查询失败!" << endl;
goto END;
}
cout << "查询成功!" << endl;
try
{
if (res->next())
{
string str;
// string str1 = string_to_utf8(str);
str = res->getString(1).c_str();
// str1 = utf8_to_string(str);
}
}
catch (const std::exception&)
{
cout << "显示失败!" << endl;
goto END;
}
END:
delete res;
delete stmt;
delete conn;
return 0;
}


str = res->getString(1).c_str();
str=张三

str = res->getString("张三").c_str();
str=20

why???

Facing issues using mysql-connector-c++ on macOS 10.14 (no replies)

$
0
0
Hello,

Ive just installed the new mysql connector c++ v8 and it is problematic.

The library is not loading and it is asking for libmysqlcppconn.7.dylib, which i symlinked in /usr/local/lib, the same for some others but now there's a boost library error.

```
dyld: Library not loaded: /usr/local/opt/mysql-connector-c++/lib/libmysqlcppconn.7.dylib
Referenced from: /Users/sagunkho/CLionProjects/Horizon/build/./../bin/char
Reason: image not found
Abort trap: 6
fun:build sagunkho$ ./../bin/char
dyld: Library not loaded: libssl.1.0.0.dylib
Referenced from: /usr/local/lib/libmysqlcppconn.7.dylib
Reason: image not found
Abort trap: 6
fun:build sagunkho$ ./../bin/char
dyld: Library not loaded: libssl.1.0.0.dylib
Referenced from: /usr/local/lib/libmysqlcppconn.7.dylib
Reason: image not found
Abort trap: 6
fun:build sagunkho$ ./../bin/char
dyld: Library not loaded: libcrypto.1.0.0.dylib
Referenced from: /usr/local/lib/libmysqlcppconn.7.dylib
Reason: image not found
Abort trap: 6
fun:build sagunkho$ ./../bin/char
dyld: lazy symbol binding failed: Symbol not found: __ZN5boost6system15system_categoryEv
Referenced from: /Users/sagunkho/CLionProjects/Horizon/build/./../bin/char
Expected in: /usr/local/opt/boost/lib/libboost_system-mt.dylib

dyld: Symbol not found: __ZN5boost6system15system_categoryEv
Referenced from: /Users/sagunkho/CLionProjects/Horizon/build/./../bin/char
Expected in: /usr/local/opt/boost/lib/libboost_system-mt.dylib

Abort trap: 6
fun:build sagunkho$

```

When compiling on xcode it asks for libmysqlcppconn8.1.dylib which is not loaded and the image isn't found.

I'm using macos 10.14 and have installed the package from the download section.

Any help will be appreciated, thanks.

Installation of the Connector/C++ 8.0.13 in MySQL installer fails on Windows 7 32-bit (1 reply)

$
0
0
I try to install Connector/C++ 8.0.13 component and use it on a freshly installed Windows 7 Professional 32-bit with January 2019 updates (KB 4480970, 44893187, 3156016, 3978601, 2952664, 29112390, 2532513 ) using the MySQL installer (mysql-installer-community-8.0.13.0.msi). Before installation I set up Visual Studio Community 2017 for C++ package (without MFC support and Windows 8.0 SDK) and had 25 GB free space on drive.

Connector/NET 8.0.13, Connector/ODBC 8.0.13, Workbench 6.3.8 and others components were installed successfully. The Connector/C++ 8.0.13 installation attempts just fails with only message:
mysql Installing 'Connector/C++ 8.0.13' for windows failed.

Looks like the incorrect installation scipt for the Connector/C++ 8.0.13. It seems me it hangs up at start because it finished too fast comparing to the other components. Probably there is incorrect registry key analysis.

I had seen no other warnings or messages that touches Connector/C++ when I tried to set up MySQL Community and add Connector/C++. I had not seen them at the first attempts, there were only errors during loading common Microsoft packages for other components of the MySQL Community at wrong addresses and I downloaded and installed them manually.

Is there known and simple workaround without compiling Connector/C++ 8.0.13?
Is it possible to enable extended output during installation process so I could help detect the issue?
What the path of the installation script for the Connector/C++ at the GitHub?

Thanks in advance,
Viacheslav K

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

Binding NULL in a prepared statement (no replies)

$
0
0
Hello,

I'm trying to bind NULL for a nullable datetime column using a prepared statement as follows -

session.sql("UPDATE `table` SET `datetime` = ? WHERE `id` = 1").bind(NULL).execute();

This crashes.

Passing null as string gives the following error - "Invalid value for datetime column: 'null'"

How do I achieve this?
Viewing all 527 articles
Browse latest View live