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

Connector c++ 8 converting field Value for DATE to time_t (16 replies)


Connector c++ 8 obtaining values from bit(1) or bit(n) fields. (no replies)

$
0
0
Selecting BIT(1) or BIT(N) fields from a table yields back a value that can not by printed, it's just a RAW 0 byte buffer, impossible to read.

I tried to select CAST( fieldname as char) but that does not return anything meaningful, neither in my code or in mysql shell:

mysql> SELECT name, owner, species, sex, CAST(birth as char) as casted_birth, CAST(bit as char), CAST(nibble as char) FROM pet;
+----------+-------+---------+------+---------------------+-------------------+----------------------+
| name | owner | species | sex | casted_birth | CAST(bit as char) | CAST(nibble as char) |
+----------+-------+---------+------+---------------------+-------------------+----------------------+
| Puffball | Diane | hamster | f | 1999-03-30 00:00:00 | |
|
+----------+-------+---------+------+---------------------+-------------------+----------------------+
1 row in set (0.00 sec)

mysql>


How does one use mysql c++connector to interpret BIT(N) values, please?

Xdevapi problem with timestamp (no replies)

$
0
0
hey

I'm using xdevapi for c++ and working with rawBtye() of Proto buff is really hard.

can we get at least helper class to convert timestamp or any raw byte as std string or something that is supported in standard library?

i think getting as string is best approach at the moment, till we get full implementation.

also, if we use server casting it is pointless to use abstraction like bind() and where() or select() and etc.

SQL via ssh (no replies)

$
0
0
Hi there,
how can i create a connection via ssh in c ++ in mysql?

It should work like this:
mysql -L -u <local database username> -h <database server ip address> -p

In any case, I would like to create the connection to the mysql database from a computer that is not in the same network and thus exchange data.

I just don't understand how I get the values ​​from mysql_real_connect (); should start.
Is there any other way that would work?

Unable to compile and run MySQL connector C++ 8.0 on Eclipse Windows - linker - MinGW (no replies)

$
0
0
09:52:18 **** Incremental Build of configuration Debug for project Database ****
Info: Internal Builder is used for build
g++ -std=c++0x "-ID:\\Downloads\\boost_1_71_0_latest" "-IC:\\Program Files\\MySQL\\Connector C++ 8.0\\include\\jdbc" "-IC:\\Program Files\\MySQL\\MySQL Server 8.0\\include" -O0 -g3 -Wall -c -fmessage-length=0 -o main.o "..\\main.cpp"
In file included from C:\Program Files\MySQL\Connector C++ 8.0\include\jdbc/cppconn/warning.h:40:0,
from C:\Program Files\MySQL\Connector C++ 8.0\include\jdbc/cppconn/connection.h:39,
from C:\Program Files\MySQL\Connector C++ 8.0\include\jdbc/mysql_connection.h:36,
from ..\main.cpp:15:
C:\Program Files\MySQL\Connector C++ 8.0\include\jdbc/cppconn/sqlstring.h:46:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
#pragma warning(push)

C:\Program Files\MySQL\Connector C++ 8.0\include\jdbc/cppconn/sqlstring.h:47:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
#pragma warning(disable: 4251)

C:\Program Files\MySQL\Connector C++ 8.0\include\jdbc/cppconn/sqlstring.h:51:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
#pragma warning(pop)

In file included from C:\Program Files\MySQL\Connector C++ 8.0\include\jdbc/cppconn/connection.h:39:0,
from C:\Program Files\MySQL\Connector C++ 8.0\include\jdbc/mysql_connection.h:36,
from ..\main.cpp:15:
C:\Program Files\MySQL\Connector C++ 8.0\include\jdbc/cppconn/warning.h:46:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
#pragma warning (disable : 4290)

In file included from ..\main.cpp:15:0:
C:\Program Files\MySQL\Connector C++ 8.0\include\jdbc/mysql_connection.h:182:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
#pragma warning(push)

C:\Program Files\MySQL\Connector C++ 8.0\include\jdbc/mysql_connection.h:183:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
#pragma warning(disable: 4251)

C:\Program Files\MySQL\Connector C++ 8.0\include\jdbc/mysql_connection.h:187:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
#pragma warning(pop)

C:\Program Files\MySQL\Connector C++ 8.0\include\jdbc/mysql_connection.h:193:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
#pragma warning(push)

C:\Program Files\MySQL\Connector C++ 8.0\include\jdbc/mysql_connection.h:194:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
#pragma warning(disable: 4251)

C:\Program Files\MySQL\Connector C++ 8.0\include\jdbc/mysql_connection.h:200:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
#pragma warning(pop)

In file included from C:\Program Files\MySQL\Connector C++ 8.0\include\jdbc/cppconn/resultset.h:36:0,
from ..\main.cpp:19:
C:\Program Files\MySQL\Connector C++ 8.0\include\jdbc/cppconn/config.h:101:19: error: conflicting declaration 'typedef long int int32_t'
typedef __int32 int32_t;
^~~~~~~
In file included from d:\mingw\lib\gcc\mingw32\6.3.0\include\stdint.h:9:0,
from d:\mingw\lib\gcc\mingw32\6.3.0\include\c++\cstdint:41,
from d:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\char_traits.h:420,
from d:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ios:40,
from d:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ostream:38,
from d:\mingw\lib\gcc\mingw32\6.3.0\include\c++\iostream:39,
from ..\main.cpp:8:
d:\mingw\include\stdint.h:62:15: note: previous declaration as 'typedef int int32_t'
typedef int int32_t;
^~~~~~~
In file included from C:\Program Files\MySQL\Connector C++ 8.0\include\jdbc/cppconn/resultset.h:36:0,
from ..\main.cpp:19:
C:\Program Files\MySQL\Connector C++ 8.0\include\jdbc/cppconn/config.h:105:26: error: conflicting declaration 'typedef long unsigned int uint32_t'
typedef unsigned __int32 uint32_t;
^~~~~~~~
In file included from d:\mingw\lib\gcc\mingw32\6.3.0\include\stdint.h:9:0,
from d:\mingw\lib\gcc\mingw32\6.3.0\include\c++\cstdint:41,
from d:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\char_traits.h:420,
from d:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ios:40,
from d:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ostream:38,
from d:\mingw\lib\gcc\mingw32\6.3.0\include\c++\iostream:39,
from ..\main.cpp:8:
d:\mingw\include\stdint.h:63:19: note: previous declaration as 'typedef unsigned int uint32_t'
typedef unsigned uint32_t;
^~~~~~~~
In file included from C:\Program Files\MySQL\Connector C++ 8.0\include\jdbc/cppconn/statement.h:36:0,
from ..\main.cpp:20:
C:\Program Files\MySQL\Connector C++ 8.0\include\jdbc/cppconn/config.h:101:19: error: conflicting declaration 'typedef long int int32_t'
typedef __int32 int32_t;
^~~~~~~
In file included from d:\mingw\lib\gcc\mingw32\6.3.0\include\stdint.h:9:0,
from d:\mingw\lib\gcc\mingw32\6.3.0\include\c++\cstdint:41,
from d:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\char_traits.h:420,
from d:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ios:40,
from d:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ostream:38,
from d:\mingw\lib\gcc\mingw32\6.3.0\include\c++\iostream:39,
from ..\main.cpp:8:
d:\mingw\include\stdint.h:62:15: note: previous declaration as 'typedef int int32_t'
typedef int int32_t;
^~~~~~~
In file included from C:\Program Files\MySQL\Connector C++ 8.0\include\jdbc/cppconn/statement.h:36:0,
from ..\main.cpp:20:
C:\Program Files\MySQL\Connector C++ 8.0\include\jdbc/cppconn/config.h:105:26: error: conflicting declaration 'typedef long unsigned int uint32_t'
typedef unsigned __int32 uint32_t;
^~~~~~~~
In file included from d:\mingw\lib\gcc\mingw32\6.3.0\include\stdint.h:9:0,
from d:\mingw\lib\gcc\mingw32\6.3.0\include\c++\cstdint:41,
from d:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\char_traits.h:420,
from d:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ios:40,
from d:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ostream:38,
from d:\mingw\lib\gcc\mingw32\6.3.0\include\c++\iostream:39,
from ..\main.cpp:8:
d:\mingw\include\stdint.h:63:19: note: previous declaration as 'typedef unsigned int uint32_t'
typedef unsigned uint32_t;
^~~~~~~~

09:52:21 Build Failed. 4 errors, 10 warnings. (took 2s.739ms)











Hi, I am unable to run and compile MySQL connector on Eclipse Window and got the above error messages. I installed MySQL connector and server - both version 8.0.25 and added "C:\Program Files\MySQL\Connector C++ 8.0\include\jdbc" and "C:\Program Files\MySQL\MySQL Server 8.0\include" onto the compile include paths and "C:\Program Files\MySQL\Connector C++ 8.0\include\jdbc", "C:\Program Files\MySQL\MySQL Server 8.0\lib" onto the MinGW C++ Linker.

Any idea how to resolve it? Any help will be greatly appreciated.

Need help with Makefile for static c++ connector (no replies)

$
0
0
I've been trying to compile a c++ program that will be run off of shared linux server I have with Bluehost. After a lot of difficulty I finally managed to successfully compile the program in linux using a makefile. However, Bluehost doesn't have the c++ connector installed, I don't have sudo privileges, and they won't install it for me. So now I'm trying to compile the program with a static version of the mysql c++ connector. I've tried to follow what is provided here: https://dev.mysql.com/doc/connector-cpp/8.0/en/connector-cpp-apps-general-considerations.html.

I am getting the following error when I try to call make: main.cpp:(.text+0x3ad): undefined reference to `get_driver_instance'

I'm hoping someone here can help sort out my makefile and get this thing working.

This is my makefile:

CC = g++

CFLAGS = -g -Wall -O0 -std=c++17

MYSQL_CONCPP_DIR= .../mysql
CPPFLAGS = -DCPPCONN_PUBLIC_FUNC= -I $(MYSQL_CONCPP_DIR)/include

LDFLAGS = $(MYSQL_CONCPP_DIR)/lib64/libmysqlcppconn8-static.a -lssl -lcrypto -lpthread

SOURCES = main.c
OBJECTS = $(SOURCES:.c=.o)
TARGET = mysqltest

$(TARGET) : $(OBJECTS)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)

.PHONY: clean

clean:
@rm -f $(TARGET) $(OBJECTS) core

mysqlx::Session memory leaks (no replies)

$
0
0
mysqlx::Client ci("mysqlx://user:password\@host:33060/db?ssl-mode=disabled");
mysqlx::Session session(ci);

Detected memory leaks!
Dumping objects ->
{23458} normal block at 0x00B44D98, 504 bytes long.
Data: < k3 p 64 Pq > 83 6B 33 01 20 70 E7 01 94 36 34 01 50 71 E7 01
{23456} normal block at 0x00AECAD8, 8 bytes long.
Data: < l > E0 6C E7 01 00 00 00 00
{22667} normal block at 0x00AEC410, 8 bytes long.
Data: <@~ > 40 7E A9 00 00 00 00 00
{22666} normal block at 0x00A97E40, 64 bytes long.
Data: < M N O > 10 C4 AE 00 98 4D B4 00 F8 4E B4 00 90 4F B4 00
{22665} normal block at 0x00AECA68, 8 bytes long.
Data: < p > 20 70 E7 01 00 00 00 00
Object dump complete.

Connector/C++ APIs document (no replies)

$
0
0
Hi All,

I'm using MySQL community version

Highly frustrated with the bad documentation that is provided for MySQL community version. I can't understand what drives this outcome

Could anyone of you find a documented list of the Connector/C++ APIs? not just the JDBC ones, but all of them including the ones that support NoSQL functionality offered by MySQL?

Please notice that I'm not referring to the 2-3 minimal examples, I'm speaking about a full list of APIs, each is documented in details

If someone could find such a link, please leave a link. Thanks in advance

Best

MySql C++ Connector Installation On Fedora 35 (no replies)

$
0
0
Hello I am new to fedora 35 and I am trying to figure out how to install the c++ header files for the mysql-connector-c++. I am a c++ dev but new to fedora.

$ sudo yum install mysql-connector-c++
Last metadata expiration check: 2:44:40 ago on Tue 08 Feb 2022 07:09:07 AM CST.
Package mysql-connector-c++-8.0.28-1.fc35.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!



I also had to install this file for the C++ header files which put them in this location.
/usr/src/debug/mysql-connector-c++-8.0.28-1.fc35.x86_64/jdbc/

sudo yum localinstall mysql-connector-c++-debugsource-8.0.28-1.fc35.x86_64.rpm



Now I am getting "build_config.h No such file or directory" inside the "connection.h" file.
Connection.h is a part of the mysql-connector package and it not a file that I wrote.
When i search "build_config.h" doesnt exist anywhere on my disk.


How can I correctly install the mysql c++ dev connector? Thanks in advance for helping me.

MySQL Now Shows its Thread Names at OS Level for Better Troubleshooting (no replies)

get date/ datetime from database (no replies)

$
0
0
Hello to all,

I try to develop a simple C++ program to get data from a MYSQL database.

One of the column has the type date and one the type datetime.

My question is now how can I get these types?

sql::ResultSet does not have methods for these types. I do not found methods for it.

Thank you,
Reinhard

Umlauts (no replies)

$
0
0
Hello,

I want to check in data with umlauts (äüö ...) and display them then in a Visual Studio 2022 app.

In a table, then these values should be displayed in a table.

But the umlauts are not shown correctly. An ? will be shown.

I tryed also to change the umlaut in the database via phpmyadmin, but then also no umlauts are shown.

Please can anyone help me?

Thank you,
Reinhard

building mysql-connector-c++ using system protobuf (no replies)

$
0
0
Part of the SynoCommunity project, looking into migrating to using mysql-connector-c++ instead of the mysql-connector-c.

Part of the issue I'm facing is that it fails at cross-compiling on non x86_64 archs as at build time it tries to use the protoc binary.

It happens that we do have a structure to cross-compile protobuf and provide host native protoc binary. And there we do provide "cross_compiling=yes --with-protoc=$(NATIVE_PROTOC)" arguments which makes it to build perfectly for all archs.

Although I can't find any cmake option to tell it to use my "system" protobuf instead of the one bundled OR to pass proper arguments so it uses the protoc binary compiled for the host platform where compiling occurs.

There is an option for WITH_SSL that work great. In comparison with the connector-c version there isn't any other WITH_* option to play with as it generates "CMake Warning: Manually-specified variables were not used by the project" otherwise.

On a similar note I also noticed it compiles the system lz4, zlib and zstd while I'd rather be using my "system" ones to avoid library collisions later down the road.

Help would be much appreciated, thnx in advance.

Proper way of using expr in complicated queries (no replies)

$
0
0
Trying to create the following query in Connector/C++ 8 (xDevAPI):
SELECT * FROM table
WHERE column1 IS NULL OR (column2 is NULL AND DATE_SUB(NOW(), INTERVAL 10 SECOND) > column1);

Not sure how to go about this WHERE part in code. Wrapping everything in expr() throws an error: CDK Error: After seeing '...IS NULL OR (column2 is NULL AND DATE_SUB(NOW(), INTERVAL ', looking at '10 SEC...': Expected ')' to close function argument list (cdk:8)

What is a proper way? Also will it work if I parametrize 10 with :timeout and then bind("timeout", 10)?

C++ Connector throws 'bad_alloc' when connect gets called (1 reply)

$
0
0
Hello guys!
I just started with MySQL and the C++ Connector. After an hour of trying to install it and include it into my project I finally figured it out. But now Ive got a new problem: When I call 'driver->connect(...)' it returns a 'bad_alloc' and the program crashes. I found two threas on stackoverflow but they have no solution. I really dont know what to do next and the doc isnt really helpfull.

Version: 8.0.28
I included the 'jdbc' folder and added the 'lib64' lib-folder. In the project settings I added "asmysqlcppconn.lib" as additional dependency (im on a german machine so idk if its called that way).

Thanks for your help guys!

MySQL 8.0.29: Release Notes (no replies)

$
0
0

Understand how float columns work (no replies)

$
0
0
I'm trying to insert a max float value to a column defined as float and I encountered out of range error. According to documenatation the maximum of float is 3.402823466E+38 but maximum float precision is 23 bits which is 7 decimal places. Now I wrote an application in c++ which inserts a values as float single-precision value 3.4028235E+38 and then error occured. In c++ these two numbers are treat as equal: 3.402823466E+38 and 3.4028235E+38 in mysql they are not, why?

And second question, what does it mean "The actual range might be slightly smaller depending on your hardware or operating system."? How the range depends on hardware? In my case described above server and client run on the same machine x86-64bit but server is 64 bit app and client 32 bit.

Using C++ Connector8 with a Dynamic Link Library (msvs19) (no replies)

$
0
0
I am trying to create a Dynamic Link Library (DLL) File with MSVS19 in c++17 code. The API I am creating the dll for is written in stdc++17.

I can created a separate project that is a console project, setup connector++ and even change the language standard to /stdc++17 and the connector works perfectly with no issues. I can create database tables, pull information, update information. When I try to add the same connector in the same way to my or to a new dynamic link library project, I get the following errors.

1>C:\plugins\mysql8.0.29-64\include\jdbc\cppconn\driver.h(74,21): error C2059: syntax error: 'function-style cast'
1>C:\plugins\mysql8.0.29-64\include\jdbc\cppconn\driver.h(74,26): error C2143: syntax error: missing ';' before '{'
1>C:\plugins\mysql8.0.29-64\include\jdbc\cppconn\driver.h(74,26): error C2447: '{': missing function header (old-style formal list?)
1>C:\plugins\mysql8.0.29-64\include\jdbc\cppconn\driver.h(75,26): warning C4002: too many arguments for function-like macro invocation 'check'
1>C:\plugins\mysql8.0.29-64\include\jdbc\cppconn\driver.h(75,21): error C2059: syntax error: 'function-style cast'
1>C:\plugins\mysql8.0.29-64\include\jdbc\cppconn\driver.h(75,26): error C2143: syntax error: missing ';' before '{'
1>C:\plugins\mysql8.0.29-64\include\jdbc\cppconn\driver.h(75,26): error C2447: '{': missing function header (old-style formal list?)
1>C:\plugins\mysql8.0.29-64\include\jdbc\cppconn\driver.h(83,3): warning C4002: too many arguments for function-like macro invocation 'check'

Any help would be appreciated.

-- Looking for sys/endian.h - not found (no replies)

$
0
0
How do you fix this?

Trying to build static library from source with JDBC, I have all the source, and boost, paths to MYSQL is set correctly. Every time I get past one error, another seems to pop up, the documentation on this is just about worthless tbh.


MSVS 2019 x64

Link error (no replies)

$
0
0
I am using the C++ connector, version 8.0.23 on Windows 10 Pro, under WSL Ubuntu 20.04.1. When I try to build my application, I get the following link error:

/usr/bin/ld: ../bin/lib/linux/Ubuntu20.04/x86_64-linux-gnu/libmysqlcppconn8-static.a(libcdk_foundation_socket_detail.cc.o): in function `cdk::foundation::connection::detail::srv_list(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
(.text+0x9b2): undefined reference to `__res_nsearch'
/usr/bin/ld: (.text+0x9fa): undefined reference to `ns_initparse'
/usr/bin/ld: (.text+0xa5a): undefined reference to `ns_parserr'
/usr/bin/ld: (.text+0xac8): undefined reference to `__dn_expand'
collect2: error: ld returned 1 exit status

The compiler is:
g++ (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Note that I am statically linking mysqlcpp, and I have -lresolv included in my command with a -L switch pointing to the dir with all the lib* files, and further, libresolv.a and .so are in that directory. My assumption is that this is a dynamic link to libresolv.so.

Further note that if I change to statically linking to libresolv by taking out -lresolv and instead using /usr/lib/x86_64-linux-gnu/libresolv.a in the linker, I do not get the error and my program works.

Finally, what is most puzzling, is that if I specify -lresolv AFTER my static link reference to mysqlcpp (in the error above, the switch was BEFORE the static link reference), then I do not get the error.

Note that I do not see this behavior using CLANG on osx.

Any ideas? Bug in g++? Does switch order matter? Should it?
Viewing all 527 articles
Browse latest View live