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

SQLException by PreparedStatement::getMoreResults in example C++ code (1 reply)

$
0
0
Hi all,

I got the following exception when running the example code here:
http://dev.mysql.com/doc/connector-cpp/en/connector-cpp-tutorials-stored-routines-prepared-statement-with-result.html

# ERR: SQLException in sp_scenario3.cpp(main) on line 70
# ERR: MySQL_Prepared_Statement::getMoreResults (MySQL error code: 0, SQLState: )


Here is the output generated by the example code:
Connector/C++ tutorial framework...

Name: Cocos (Keeling) Islands Population: 600
Name: Christmas Island Population: 2500
Name: Norfolk Island Population: 2000
Name: Niue Population: 2000
Name: Pitcairn Population: 50
Name: Tokelau Population: 2000
Name: United States Minor Outlying Islands Population: 0
# ERR: SQLException in sp_scenario3.cpp(main) on line 70
# ERR: MySQL_Prepared_Statement::getMoreResults (MySQL error code: 0, SQLState: )

It seems that the error was generated by calling pstmt->getMoreResults() in the if condition.

I'm running the packages on Ubuntu 14.04 LTS and the version of mysql connector/c++ is 1.0.2 according to Software Center. I'd really appreciate it if anyone could help!

How do I set the LOCAL INFILE option (for load data file command) using setClientOption (no replies)

$
0
0
I am writing a C++ function using the C++ connector library that will take a table name and data file name and will use
the LOAD DATA command to bulk load the data from the file. How can i set the LOCAL_INFILE parameter for the connection to true.

Exit clean up when use "sql::Connection" after network disabled. (no replies)

$
0
0
Hello ^^

I'm new on using mysql_cpp_conn with c++ and having a problem.


below is my testing code,
-----------------------------------------------

sql::Connection * _con;
sql::Statement * _stmt;

...


try {
if (false == _con->isValid()){ // ----------- A
return false;
}
_pstmt = _con->prepareStatement(string); // ------------ B
}catch (sql::SQLException &e) {
manageException(e); // ------------ C
return false;
}
-----------------------------------------------
this works well in normal situation. but in my testing scenarios this code
exit clean up. no throwing exceptions.


[ my scenario ]

1. procses start~

2. breaking points at code [A, b, C]

3. run code [A] -> it's ok

3. disable ethernet adaptor! it's simulation for ethernet-adaptor's hardware faults.

4. run code B -> exit clean up. process terminated. no exceptions.

* in case unpluged rj45 cable, it's throw SQLException. but in case disabled ethernet adaptor, it's just exit process.


it's ok function's failed but i want to keep running my process not exit.

THX

Ineffective Prepared Delete Statement (no replies)

$
0
0
I'm attempting to execute a prepared delete statement like so:

prep_stmt = conn->prepareStatement("DELETE FROM my_table WHERE my_column = ?");

sql::SQLString test_string = "\'asdf\'";

prep_stmt->setString(1, test_string);

int update_count = prep_stmt->executeUpdate();

There appears to be no runtime errors (at least, no exception is thrown). However, update_count is zero, and investigating the contents of the database after execution reveals that the associated data entry was not removed.

Has anyone seen this before?

C++ Connector / Json / Prepared Statements (no replies)

$
0
0
For a JSON datatype which 'set' method should I use?

for a string ...

prep_statement->setString(2, pseudojson);

mysqlcppconn.dll RUNTIME advice and help (2 replies)

$
0
0
Hi to all,

I would like to know
1. if it is possible to use mysql connector for c++ without the need of the
mysqlcppconn.dll to be external (if it can be embed inside my executable c++ app and stay embed inside it while running)
2. if 1 can`t be possible at least can this mysqlcppconn.dll be embed inside my app and when my application starts exports the mysqlcppconn.dll to a folder so it can be used by mysql connector c++ inside my app and then when my application closes delete this mysqlcppconn.dll file ?

Can anyone give me a clear answer i would at least like to have one of this options for my c++ win32 app executable with the use of mysql c++ connector

Unresolved Externals (1 reply)

$
0
0
Hello i have a problem with this mysql c++ connector i setup everything all includes and libraries and is still gives me an errors :
What have i done so far :

Additional Include Directories : ...MySQL\MySQL Connector C++ 1.1.7\include

Also have boost installed because it was missing :MySQL\MySQL Connector C++ 1.1.7\include\boost

Additional Library Directories :MySQL\MySQL Connector C++ 1.1.7\lib\opt
There was missing some libraries but i got them from Mysql server that i download from mysql.com

Additional Dependencies: mysqlcppconn-static.lib and libmysql.lib
i havent done last step width CPPCONN_PUBLIC_FUNC= because once i do that i got like 300 errors

my code looks like this :
sql::mysql::MySQL_Driver* driver;
sql::Connection* con;

driver = sql::mysql::get_mysql_driver_instance();
con = driver->connect(cfg->GetDatabase()->host, cfg->GetDatabase()->username, cfg->GetDatabase()->password);

delete con;

build 2.0.3 source on minGW64 fails (1 reply)

$
0
0
Hello,
I am trying to build Connector/C++ 2.0.3 source on windows10 64bit with mingw64 6.2.0 installed (x86_64-6.2.0-posix-seh-rt_v5-rev1).
cmake configuration runs fine. However, I got below errors and do not know how to proceed. Would you please help me? Thanks a lot.

C:\mysql-connector-cpp-2.0>cmake --build . --config Debug
cdk/mysqlx/CMakeFiles/cdk_mysqlx.dir/flags.make:6: *** missing separator. Stop.
CMakeFiles\Makefile2:717: recipe for target 'cdk/mysqlx/CMakeFiles/cdk_mysqlx.dir/all' failed
mingw32-make.exe[1]: *** [cdk/mysqlx/CMakeFiles/cdk_mysqlx.dir/all] Error 2
Makefile:126: recipe for target 'all' failed
mingw32-make.exe: *** [all] Error 2

mixing mingw64 gcc and prebuilt vs14 2.0.3 library (2 replies)

$
0
0
Hello,
I try to compile the example given by

using ming64 6.2.0 on windows10 64bit machine. I use the prebuilt vs14 2.0.3 library. None of the connector API implementations can be found whether I use static or dynamic mysqlcppconn2. Do I have to build the connector from source using mingw64 gcc/g++ before I can use it? Any missing steps? Thank you very much.

g++.exe -w -std=c++11 -m64 -g -fexceptions -I"C:\Program Files\MySQL\mysql-connector-c++-2.0.3-windows-x86-64bit\include" -c C:\Users\lampa\Documents\RFID\readRFID\main.cpp -o obj\Debug\main.o
g++.exe -L"C:\Program Files\MySQL\mysql-connector-c++-2.0.3-windows-x86-64bit\lib64\vs14" -o bin\Debug\readRFID.exe obj\Debug\main.o -m64 -lmysqlcppconn2 -lpthread
obj\Debug\main.o: In function `main':
C:/Users/lampa/Documents/RFID/readRFID/main.cpp:43: undefined reference to `mysqlx::internal::XSession_base::getSchema(mysqlx::string const&, bool)'
C:/Users/lampa/Documents/RFID/readRFID/main.cpp:44: undefined reference to `mysqlx::Schema::createCollection(mysqlx::string const&, bool)'
C:/Users/lampa/Documents/RFID/readRFID/main.cpp:50: undefined reference to `mysqlx::Result::getDocumentId() const'

Connector/C++ fror OSX (1 reply)

$
0
0
Hi, ALL,
On the download page for MySQL Connector/C++ for OSX it is said that it is compatible with 10.12, 10.11 and 10.10 for the latest version.

There is also a link on that page which says: "Looking for previous GA version?" When clicking on that link you will be able to download the versions for 10.4 and 10.5.

I'm curious - where can I download the version for 10.6 - 10.9?
And also out of curiosity - who decides when to stop supporting the OSX version?

Thank you.

P.S.: If someone has a version of the connector which can be installed on OSX 10.8, I will appreciate the link to download. Hopefully Oracle will not punish you - I'm not asking for an actual DBMS, just for the library that I can use to access it from my software. I just hate when the company does not support something that is still on the market...

windows example fails STRING TOO LONG (1 reply)

$
0
0
Hello,
I installed vs14 2015 linked to vs14 version of 2.0.3 prebuild library. I created a project with the exact source code from
http://dev.mysql.com/doc/dev/connector-cpp/devapi_ref.html

When I run the example, I got
Creating session on localhost, port 33060 ...
STD EXCEPTION: string too long
The exception happens at Impl::from_utf8(*this, utf8) where utf8="root".
// TODO: make utf8 conversions explicit

string(const char *other)
{
if (!other)
return;
std::string utf8(other);
--> Impl::from_utf8(*this, utf8);
}


catch (std::exception &ex)
{
cout << "STD EXCEPTION: " << ex.what() << endl;
return 1;
}

Would you please help?

driver->connect() Segmentation Fault (6 replies)

$
0
0
I could compile this code with no error messages. But when I execute the binary I get a segmentation fault error. The problem is in this line:

con = driver->connect("tcp://127.0.0.1:3306", "root", "*******");

I've tried a lot of things and I'm out of ideas. Even though compilation was ok, maybe I made a mistake there somehow.
If you can help me I will really appreciate it.

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


#include <stdlib.h>
#include <iostream>
#include "mysql_connection.h"
#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>

using namespace std;

int main(void)
{
cout << endl;
cout << "Running 'SELECT 'Hello World!' AS _message'..." << endl;

try {
sql::mysql::MySQL_Driver *driver;
sql::Connection *con;
sql::Statement *stmt;
sql::ResultSet *res;

driver = sql::mysql::get_mysql_driver_instance();
con = driver->connect("tcp://127.0.0.1:3306", "root", "*******");

} catch (sql::SQLException &e) {
cout << "# ERR: SQLException in " << __FILE__;
cout << "(" << __FUNCTION__ << ") on line "<< __LINE__ << endl;
cout << "# ERR: " << e.what();
cout << " (MySQL error code: " << e.getErrorCode();
cout << ", SQLState: " << e.getSQLState() << " )" << endl;
}

cout << endl;

return EXIT_SUCCESS;
}

Segmentation Fault on Example Program (no replies)

$
0
0
I am using Mac OS X Yosemite version 10.10.5. I downloaded the connector/c++ library from the mysql developer website. I untared the files and installed them in /usr/local/mysql-connector-c++-1.1.6-osx10.8-x86-64bit. I created a simple makefile. Everything compiles and links fine, but when I run it, I get a segmentation fault 11. Why?

#locations to library directories
CONNECTOR_C_PATH = /usr/local/mysql-connector-c-6.1.6-osx10.8-x86_64
CONNECTOR_CPP_PATH = /usr/local/mysql-connector-c++-1.1.6-osx10.8-x86-64bit
BOOST_PATH = /usr/local/Cellar/boost/1.58.0

#specific configuration for this build
INCLUDE_PATHS = -I $(CONNECTOR_CPP_PATH)/include -I $(BOOST_PATH)/include
LIB_PATHS = -L $(CONNECTOR_CPP_PATH)/lib -L $(BOOST_PATH)/lib
LIBS = -l mysqlcppconn
COMPILE_OPTS = $(INCLUDE_PATHS) 
LINK_OPTS = $(LIB_PATHS) $(LIBS)
CPP = g++
COMPILE = $(CPP) $(COMPILE_OPTS) -c
LINK = $(CPP) $(LINK_OPTS) -o

all: sqltest

# Create the server
sqltest: main.o 
	 $(LINK) sqltest main.o

main.o: main.cpp
	$(COMPILE) main.cpp

clean:
	-rm *.o sqltest

Error in compling the examples (no replies)

$
0
0
I downloaded the connector for c++ and installed it following the steps provided on the website. Every step was succeed. But when I changed to path of example and compiled a program, none could compile successfully. The error was mainly about "undefined reference to `sql::mysql::get_driver_instance()'" and "fatal error: driver/mysql_public_iface.h: No such file or directory". Of course, I had used the command "export ..." . My compile-command was"g++ -o connect -I/usr/local/include -I/usr/local/include/cppconn -Wl, -Bdynamic -lmysqlcppconn connect.cpp". Why there were errors. Anyone can help me. Thank you.

Basic of c programming (2 replies)

$
0
0
Computer programming means giving instruction to the computer and to interact with the computer we need a language to communicate with it, there are many languages such as C, C++, Java, Python each having their own features. Let's discuss first why we need programming suppose you are given ten numbers and asked to arrange them in ascending order then you can do it easily, but what if the numbers are say ten thousand it will be a difficult task and may take a long time and result may also contain errors, to simplify we can write a program which does this task and if the algorithm is correct then we will get result accurately and quickly, this is where programming is helpful.

Compiling connector/C++ with Visual Studio 2015 (13 replies)

$
0
0
Hi guys,

I am porting a project from Visual Studio 2010 to Visual Studio 2015. However, I find that I need to recompile connector/c++ which I use. However, I get errors of the kind:
Severity Code Description Project File Line Suppression State
Error C2011 'timespec': 'struct' type redefinition mysqlcppconn c:\program files (x86)\mysql\mysql connector.c 6.1\include\my_global.h 660

I understand this has to do with that there are new things in VS2015 that conflict with MySQL code. I read that this should have been resolved in latest version, but I get the same issues. I would very much appreciate any input on this matter. In particular from MySQL staff, giving some updated hints on how to work with connector/c++ and Visual Studio 2015.

Connector/C++ documentation? (3 replies)

$
0
0
Hi to everyone,

there are some kind of documentations about MySql C++ Connector?
Such as function or method list description

I've tried to search in forum, in dev.myslq.com/doc/, but i've found only usage examples.

Any suggestions?

Thanks in advance

MySQL Connector C++ Make Errors (1 reply)

$
0
0
Hello,

I am trying to run make on the c++ connector but i receive the following errors:


make
Scanning dependencies of target mysqlcppconn
[ 0%] Building CXX object driver/CMakeFiles/mysqlcppconn.dir/mysql_art_resultset.o
[ 1%] Building CXX object driver/CMakeFiles/mysqlcppconn.dir/mysql_art_rset_metadata.o
[ 2%] Building CXX object driver/CMakeFiles/mysqlcppconn.dir/mysql_connection.o
/usr/labor/bin/PMG/mysql-connector-c++-1.0.5/driver/mysql_connection.cpp: In member function `void sql::mysql::MySQL_Connection::init(std::map<std::string, sql::ConnectPropertyVal, std::less<std::string>, std::allocator<std::pair<const std::string, sql::ConnectPropertyVal> > >&)':
/usr/labor/bin/PMG/mysql-connector-c++-1.0.5/driver/mysql_connection.cpp:367: error: `MYSQL_OPT_RECONNECT' was not declared in this scope
/usr/labor/bin/PMG/mysql-connector-c++-1.0.5/driver/mysql_connection.cpp:367: warning: unused variable 'MYSQL_OPT_RECONNECT'
/usr/labor/bin/PMG/mysql-connector-c++-1.0.5/driver/mysql_connection.cpp:371: error: `MYSQL_REPORT_DATA_TRUNCATION' was not declared in this scope
/usr/labor/bin/PMG/mysql-connector-c++-1.0.5/driver/mysql_connection.cpp:371: warning: unused variable 'MYSQL_REPORT_DATA_TRUNCATION'
make[2]: *** [driver/CMakeFiles/mysqlcppconn.dir/mysql_connection.o] Error 1
make[1]: *** [driver/CMakeFiles/mysqlcppconn.dir/all] Error 2
make: *** [all] Error 2

Installing on Linux Red Hat Enterprise Linux ES release 4 (Nahant Update 5)

I have the following MySQL server version: server version: 4.1.22-standard-log

I am not sure how to check the MySQL client library version

Any ideas?

R language (1 reply)

$
0
0
R Language i.e. Stands for Rintro Language. Basically it is a platform used for statically and graphics. It also provide us linear or non-linear modeling, Classification etc. One advantage of R Language it can easy the designing of our graphics. It is open and freely available. It can Compile in these types of Operating Systems ( Linux, Mac OS , Windows).

Features of R Language (no replies)

$
0
0
Features of R Language:
4 Basic programming language features
a) Input/Output
b) Object Oriented Programming
c) Including R Packages
d) Distributed Computing
Viewing all 529 articles
Browse latest View live


Latest Images

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