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

free() invalid pointer in prepared statement (1 reply)

$
0
0
Hi,

This may end up in finger pointing but i have to start somewhere...

I am on RedHat 6.7; I have the most recent MySQL yum repo versions of everything

mysql-community-server.x86_64 5.6.27-2.el6 plus the client and libs
mysql-connector-c++.x86_64 1.1.6-1 plus most of the other conntors

I have a C++ project that consists of an executable; a ".so" plugin for PAM (Pluggable Auth Modules); and, a library that allows the first two things to actually operate. The library, amoung other things, inserts records into a remote MySQL database during user login "session" starts and stops.

This works for the commandline exectuable. This works for what I consider "normal" PAM operations like SSH and GDM. If you are unaware, PAM is an authentication layer that, by default, sits between system and user level applications and /etc/passwd or LDAP or AD or ...

So for most of my use cases this all works, no problem. I have a case where it dramatically fails though.

There is a Linux "remote desktop" service called "xrdp". Windows clients can RDP to Linux servers running xrdp and get linus desktop environments. My PAM module (the exact same code that works for SSH and console logins) blows up on the first prepared "stmt->execute();" or the close or the delete that comes after it. My diagnostic prints don't make it out in time to know which element is actually crashing.

The first part of the message I get is:

*** glibc detected *** /usr/sbin/xrdp-sesman: free(): invalid pointer: 0x00000000015be9b0 ***
======= Backtrace: =========
/lib64/libc.so.6[0x3479275f4e]
/lib64/libc.so.6[0x3479278cad]
/usr/local/sbin/myPlugin/pam_myPlugin.so(mysql_stmt_close+0x54)[0x7fca9e1703d4]
/usr/local/sbin/myPlugin/pam_myPlugin.so(_ZN3sql5mysql9NativeAPI19LibmysqlStaticProxy10stmt_closeEP13st_mysql_stmt+0xc)[0x7fca9e16db80]
/usr/local/sbin/myPlugin/pam_myPlugin.so(_ZN3sql5mysql9NativeAPI28MySQL_NativeStatementWrapperD1Ev+0x35)[0x7fca9e127ee3]
/usr/local/sbin/myPlugin/pam_myPlugin.so(_ZN3sql5mysql9NativeAPI28MySQL_NativeStatementWrapperD0Ev+0x9)[0x7fca9e127fa5]
/usr/local/sbin/myPlugin/pam_myPlugin.so(_ZN5boost6detail17sp_counted_impl_pIN3sql5mysql9NativeAPI22NativeStatementWrapperEE7disposeEv+0x13)[0x7fca9e131911]
/usr/local/sbin/myPlugin/pam_myPlugin.so(_ZN3sql5mysql31MySQL_PreparedResultSetMetaDataD1Ev+0xa3)[0x7fca9e1658ad]
/usr/local/sbin/myPlugin/pam_myPlugin.so(_ZN3sql5mysql31MySQL_PreparedResultSetMetaDataD0Ev+0x9)[0x7fca9e1658ff]
/usr/local/sbin/myPlugin/pam_myPlugin.so(_ZN3sql5mysql24MySQL_Prepared_StatementD2Ev+0xbd)[0x7fca9e15b769]
/usr/local/sbin/myPlugin/pam_myPlugin.so(_ZN3sql5mysql24MySQL_Prepared_StatementD0Ev+0x9)[0x7fca9e15b883]
...


My code in this section looks like (edited for brevity):


/* Create a connection */
driver = get_driver_instance();
con = driver->connect("my.host", "myUser", "passwird");

/* Connect to the MySQL test database */
con->setSchema("myDB");

MyPlugin_Lib::EventRecord item;
for (int i = 0; !eventList.empty(); eventList.pop_front(), i++) {
try {
item = eventList.front();

std::string dateTmp = MyUtilities::MyUtilities::UpperCase(item.getDate().c_str());


snprintf(insertSQL, 1024,
"INSERT INTO %s (event) VALUES(UPPER(?))",
MyPlugin_Lib::MySQLDBCpp::DBMyPluginTableName.c_str());

sql::PreparedStatement *sth = con->prepareStatement(insertSQL);

int col = 1;

sth->setString(col++, item.getEvent().c_str());
#ifdef DEBUG_2
syslog(LOG_AUTHPRIV | LOG_DEBUG, "%s: event=%s",
__func__, item.getEvent().c_str());
#endif

#ifdef DEBUG_2
syslog(LOG_AUTHPRIV | LOG_DEBUG,
"%s: before execute", __func__);
#endif
sth->execute();
#ifdef DEBUG_2
syslog(LOG_AUTHPRIV | LOG_DEBUG,
"%s: after execute", __func__);
#endif
sth->close();
#ifdef DEBUG_2
syslog(LOG_AUTHPRIV | LOG_DEBUG,
"%s: after close", __func__);
#endif

delete sth;
#ifdef DEBUG_2
syslog(LOG_AUTHPRIV | LOG_DEBUG,
"%s: after delete", __func__);
#endif
sth = NULL;
} catch (MyUtilities::MyException & e) {
sprintf(error,
"%s: userTracking DB insert failed: %s",
__func__, e.what());
syslog(LOG_AUTHPRIV | LOG_DEBUG, "%s", error);
throw MyUtilities::MyException(error);
} catch (...) {
syslog(LOG_AUTHPRIV | LOG_DEBUG,
"%s: unknown exception", __func__);
}
}

delete con;


the execute does not happen and the syslog statement just before it and all of them after do not reach the log

I am looking for ideas. Attaching to the/a process in this case to try to debug seems like a non-starter as PAM is not "running".

The procedure entry point mysql_get_option could not be located in the dynamic link library libmysql.dll (no replies)

$
0
0
I am getting this error when trying to run my program. It compiles fine and will even run if I compile with debug in VS2013. If I switch over to release compile then I run into this problem. I have downloaded and compiled the c++ connectors and c connectors. That all compiles fine with no errors. The project is finding all the lib and dll files it needs. I am just running into problems with mysql_get_option function. I just took the example code from this site on the c++ connectors section to test for this problem. Only thing that was changed was connecting to my database.

Thank you for your time,


P.S
I program as a hobby.

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 (no 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 (no 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? (no 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 (no replies)

$
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

C++ Project (no replies)

$
0
0
Which is the best topic for my project and easy to implemented?

C++ Basics (no replies)

$
0
0
What is the main role of #include in C programing?Explain!

C API Support for calling mysql stored procedure - Not working in case of string argument (1 reply)

$
0
0
Below code works fine in case of integer argument like CREATE PROCEDURE p1(IN p_in INT)but not for varchar arguments.
varchar input parameter type is MYSQL_TYPE_STRING and output parameter type is MYSQL_TYPE_VAR_STRING
Problem: Getting empty result. As far my analysis, status = mysql_stmt_fetch(stmt); function returns 100(MYSQL_NO_DATA) though the entry present in the table.
NOTE: I tried calling the procedure manually into mysql like call p1('6666600222'); which results
mysql> call p1('6666600222');
+----------+
| password |
+----------+
| 1234 |
+----------+
1 row in set (0.00 sec)
Anyone help me to short out this?



I'm in the phase of developing a C project which interacts with mysql. So i planned to use mysql stored procedure and found a sample program in this link I just changed the program according to the requirements of my project. Here is the table structure

id | int(10) unsigned | NO | PRI | NULL | auto_increment |
username | varchar(64) | NO | MUL | NULL | |
password | varchar(25) | NO | | NULL | |


int main()
{
MYSQL_RES *result;
MYSQL *mysql=mysql_init(NULL);

/* connect to server with the CLIENT_MULTI_STATEMENTS option */
if (mysql_real_connect (mysql, "localhost", "root", "root123","DONT_USE", 0, NULL , CLIENT_MULTI_STATEMENTS) == NULL)
{
printf("mysql_real_connect() failed\n");
mysql_close(mysql);
}


MYSQL_STMT *stmt;
MYSQL_BIND ps_params[1]; /* input parameter buffers */
long int int_data[3]; /* input/output values */
my_bool is_null[3]; /* output value nullability */
int status;
char own_buf[25],input_buf[64];
memset(own_buf, 0, 25);
memset(input_buf, 0, 64);

/* set up stored procedure */
status = mysql_query(mysql, "DROP PROCEDURE IF EXISTS p1");
test_error(mysql, status);

status = mysql_query(mysql,
"CREATE PROCEDURE p1("
" IN p_in VARCHAR(64)) "
"BEGIN "
" SELECT password from data where username=p_in; "
"END");
test_error(mysql, status);

/* initialize and prepare CALL statement with parameter placeholders */
stmt = mysql_stmt_init(mysql);
if (!stmt)
{
printf("Could not initialize statement\n");
}
status = mysql_stmt_prepare(stmt, "CALL p1(?)", 10);
test_stmt_error(stmt, status);

/* initialize parameters: p_in, p_out, p_inout (all INT) */
memset(ps_params, 0, sizeof (ps_params));

ps_params[0].buffer_type = MYSQL_TYPE_STRING;
ps_params[0].buffer = (void *) &input_buf;
ps_params[0].buffer_length = sizeof(input_buf);
ps_params[0].is_null = 0;

/* bind parameters */
status = mysql_stmt_bind_param(stmt, ps_params);
test_stmt_error(stmt, status);

/* assign values to parameters and execute statement */
int_data[0]= 2; /* p_in */
int_data[1]= 20; /* p_out */

strcpy(input_buf,"'6666600222'");
int_data[0] = strlen(input_buf);
input_buf[int_data[0]] = '\0';
ps_params[0].length = &int_data[0];


status = mysql_stmt_execute(stmt);
test_stmt_error(stmt, status);

/* process results until there are no more */
do {
int i;
int num_fields; /* number of columns in result */
MYSQL_FIELD *fields; /* for result set metadata */
MYSQL_BIND *rs_bind; /* for output buffers */

/* the column count is > 0 if there is a result set */
/* 0 if the result is only the final status packet */
num_fields = mysql_stmt_field_count(stmt);

if (num_fields > 0)
{
/* there is a result set to fetch */
printf("Number of columns in result: %d\n", (int) num_fields);

/* what kind of result set is this? */
printf("Data: ");
if(mysql->server_status & SERVER_PS_OUT_PARAMS)
printf("this result set contains OUT/INOUT parameters\n");
else
printf("this result set is produced by the procedure\n");

MYSQL_RES *rs_metadata = mysql_stmt_result_metadata(stmt);
test_stmt_error(stmt, rs_metadata == NULL);

fields = mysql_fetch_fields(rs_metadata);

rs_bind = (MYSQL_BIND *) malloc(sizeof (MYSQL_BIND) * num_fields);
if (!rs_bind)
{
printf("Cannot allocate output buffers\n");
}
memset(rs_bind, 0, sizeof (MYSQL_BIND) * num_fields);

/* set up and bind result set output buffers */
for (i = 0; i < num_fields; ++i)
{
rs_bind.buffer_type = fields.type;
rs_bind.is_null = &is_null;

switch (fields.type)
{
case MYSQL_TYPE_LONG:
rs_bind.buffer = (char *) &(int_data);
rs_bind.buffer_length = sizeof (int_data);
break;
case MYSQL_TYPE_VAR_STRING:
rs_bind.buffer = (char *) own_buf;
rs_bind.buffer_length = sizeof(own_buf);
rs_bind.length = &int_data[1];
break;

default:
fprintf(stderr, "ERROR: unexpected type: %d.\n", fields.type);
}
}

status = mysql_stmt_bind_result(stmt, rs_bind);
test_stmt_error(stmt, status);

/* fetch and display result set rows */
while (1)
{
status = mysql_stmt_fetch(stmt);

if (status == 1 || status == MYSQL_NO_DATA)
break;

for (i = 0; i < num_fields; ++i)
{
switch (rs_bind.buffer_type)
{
case MYSQL_TYPE_LONG:
if (*rs_bind.is_null)
printf(" val[%d] = NULL;", i);
else
printf(" val[%d] = %ld;",
i, (long) *((int *) rs_bind.buffer));
break;
case MYSQL_TYPE_VAR_STRING:
printf(" val[%d] = %s;",i,(char*)rs_bind.buffer);
break;

default:
printf(" unexpected type (%d)\n",
rs_bind.buffer_type);
}
}
printf("\n");
}

mysql_free_result(rs_metadata); /* free metadata */
free(rs_bind); /* free output buffers */
}
else
{
/* no columns = final status packet */
printf("End of procedure output\n");
}

/* more results? -1 = no, >0 = error, 0 = yes (keep looking) */
status = mysql_stmt_next_result(stmt);
if (status > 0)
test_stmt_error(stmt, status);
} while (status == 0);

mysql_stmt_close(stmt);
}

OUTPUT:
Number of columns in result: 1
Data: this result set is produced by the procedure
End of procedure output

Mysql c++ application help (2 replies)

$
0
0
I was wondering if anyone can help me figure how to do something. I have created an C++ application with a menu that links to mySql database to pull data from. I have managed to pull data from my program to display it in c++ but the output formatting is total messed up. I have tried to make it look nice but my data doesn't seem to line up correctly.

So I was wondering if someone could tell me how to fix my formatting issue?

Another question is how to add data into mySQL database because one of the options is to add some data into a field. I have checked this online but can't seem to find exactly how to do this.

My query for option 2 and 3 don't seem to work, can you help me fix them?

My C++ program:

#include <stdio.h>
#include <mysql.h>
#include <iostream>
#include <iomanip>
using namespace std;
#define SERVER "students"
#define USER "********"
#define PASSWORD "*********"
#define DATABASE "cs566402"

int main() {

MYSQL *connect, mysql; //Creates a pointer to the MySQL instance
connect = mysql_init(&mysql); // Initialize the instance
connect = mysql_real_connect(connect, SERVER, USER, PASSWORD, DATABASE, 0, NULL, 0); //Connect to the specific database
if (connect) {
cout << "connection Succeeded\n";
} else {
cout << "connection failed\n";
}
MYSQL_RES *res_set;
MYSQL_ROW row;

cout << endl;
int option;
do {
cout << "1) List all wines that any winery produces " << endl;
cout << "2) List all wineries in a particular region " << endl;
cout << "3) List all wines with all of the grape varieties included in each wine" << endl;
cout << "4) Add a new winery (when adding a winery
there is no need for it to have any wines associated, but you must be able to put it in an existing
region)" << endl;
cout << "5) Exit Program " << endl;
cout << endl;
//Prompting user to enter an option according to menu
cout << "Please select an option : ";
cout << endl;
cin >> option; // taking option value as input and saving in variable "option"

if (option == 1) // Checking if user selected option 1
{
mysql_query(connect, "select w.WineId, w.WineName, wn.WineryName from Wine w, Winery wn where w.WineryId = wn.WineryId");
unsigned int i = 0;
res_set = mysql_store_result(connect);
unsigned int numrows = mysql_num_rows(res_set);

cout << setfill('-') << setw(1) << "+" << setw(11) << "-" << setw(1) << "+" << setw(45) << "-" << setw(1) << "+" << setw(30) << "-" << setw(1) << "+" << endl;
cout << setfill(' ') << setw(31) << left << "WineId" << setw(33) << left << "WineName" << setw(24) << left << "WineryName" << endl;
cout << setfill('-') << setw(1) << "+" << setw(11) << "-" << setw(1) << "+" << setw(45) << "-" << setw(1) << "+" << setw(30) << "-" << setw(1) << "+" << endl;

while (((row = mysql_fetch_row(res_set)) != NULL)) { //cout<<" %s\n",row !=NULL?row : "NULL";

cout << setw(1) << left << row << " \t \t" << setw(31) << row[i + 1] << " \t \t" << setw(11) << right << row[i + 2] << endl;
}
} else if (option == 2) // Checking if user selected option 2
{
mysql_query(connect, "select WineryName, Region from Winery");
unsigned int i = 0;
res_set = mysql_store_result(connect);
unsigned int numrows = mysql_num_rows(res_set);
while (((row = mysql_fetch_row(res_set)) != NULL)) { //cout<<" %s\n",row !=NULL?row : "NULL";

cout << "|" << row << "| \t";
cout << row[i + 1] << endl;
}
} else if (option == 3) // Checking if user selected option 3
{
mysql_query(connect, "select g.GrapeType, w.WineName from GrapeType g, Wine w, Varieties v where g.GrapeId = v.GrapeId and v.WineId = w.WineId");
unsigned int i = 0;
res_set = mysql_store_result(connect);
unsigned int numrows = mysql_num_rows(res_set);
while (((row = mysql_fetch_row(res_set)) != NULL)) { //cout<<" %s\n",row !=NULL?row : "NULL";

cout << "|" << row << "| \t";
cout << row[i + 1] << endl;
}
} else if (option == 4) // Checking if user selected option 3
{

} else if (option == 5) // Checking if user selected option 4
{
cout << "Terminating Program" << endl;
} else //if user has entered invalid choice (other than 1,2,3,4, or 5)
{
//Displaying error message
cout << "Invalid Option entered" << endl;
}
} while (option != 5); //condition of do-while loop

//return 0;



mysql_close(connect);
return 0;
}

Segmentation fault when inserting a large string (no replies)

$
0
0
I have a repeatable segmentation fault when using prepared statements with large chunks of data bound to a mediumblob data type. I’ve searched the outstanding bugs, but can’t find anything relevant, and just wanted to sanity check what I’m doing, before I go ahead and create a new bug.

My code is well established and has been working in a variety of iterations for years, but I noticed recently that one subroutine that loads files into a database was failing on a new example, which was larger than prior files.

The code is fully unit tested, and larger read and writes are working as expected within the tests.

When I looked at the failing section, the parameter had been bound to a std::string using setString, rather than a stream and setBlob. In all cases, the segmentation fault was triggered when execute was issued.

Off the back of this, I added additional tests and the results I found were:

setString fails at ~250k with a segmentation fault
getString, setBlob and getBlob all work fine, and appear only limited by max_allowed_packet

I’m a bit of an anal coder, and the compiler generates no warnings, plus a valgrind run with a smaller file generates no errors at all.

With a large file, the segmentation fault is generated, and valgrind reports (heavily abridged):
Conditional jump or move depends on uninitialised value(s)
Uninitialised value was created by a stack allocation
sql::mysql::MySQL_Prepared_Statement::execute() (in /usr/lib/libmysqlcppconn.so.7.1.1.3)

Which looks like the library code has tried to allocate the string on the stack, failed, but has not checked the return before using it.

Code versions:
libmysqlcppconn.so.7.1.1.3
libmysqlclient.so.18.1.0

i got the below errors while executing the visual studio c++ console application (1 reply)

$
0
0
i have written the code in visual studio c++ in console application in that i am trying to connect to mysql database but i am getting the following errors

1) unresolved external symbol _mysql_close@4 referenced in function _main PDIconsole

2)unresolved external symbol _mysql_error@4 referenced in function _main PDIconsole

3)unresolved external symbol _mysql_free_result@4 referenced in function _main PDIconsole

4)unresolved external symbol _mysql_fetch_row@4 referenced in function _main

5)unresolved external symbol _mysql_init@4 referenced in function _main PDIconsole
6)unresolved external symbol _mysql_query@8 referenced in function _main PDIconsole

7)unresolved external symbol _mysql_real_connect@32 referenced in function _main PDIconsole

8)unresolved external symbol _mysql_use_result@4 referenced in function _main PDIconsole

MySql C++ connector - conn->commit() doesn't throw exception (no replies)

$
0
0
Hi,
sql::Connection *conn
I observed that conn->commit() doesn't throw exception if client loses connection to mysql server just before executing this commit statement.

As no exception is thrown client gets a wrong impression that the transaction was committed whereas actually it was not!

Is this a MYSQL C++ connector bug ?

Regards,
Akshay

how to escape strings in mysqlcppconn (no replies)

$
0
0
Hello,
i wrote a C++ program and using the mysqlcppconn library.
Now i would love to escape sql special characters for make it more stable and save.
I don't know how to do with that API. Of course i just can use the C api.
But before i mix APIs i would like to ask if there is somebody who knows how to escape these chars with mysqlcppconn.

Regards
FK

std::bad_alloc thrown on attemt to setSchema (1 reply)

$
0
0
Hi -- I have this really simple code:

auto mysql_driver = get_driver_instance();
sql::Connection *c = mysql_driver->connect("172.17.0.1", "root", "tooth");
c->setSchema("mysql");
delete c;

That is generating this error:

terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
Aborted

The following command however works in the terminal:
$ mysql -h 172.17.0.1 -u root -ptooth mysql

If I comment out the line with the call to setSchema() in it, no error is thrown, so it looks like the first attempt to (presumably lazy-) use the connection is causing the error.

I'm on linux, and installed Connector/C++ from the tar file.

Could anybody please advise me on what is going wrong, here? I've been trying to fix this for hours, now, but to no avail.
Thanks in advance for any & all assistance,
Doug.

Error trying to connect to MySQL with Eclipse (no replies)

$
0
0
Hello,

I am trying to connect to the MySQL Database using Eclipse for C++.

I have added the dynamic library mysqlcppconn.lib and also have the relevant dll files in my executable folder

I get the exact error
"
relocation truncated to fit: R_X86_64_32 against symbol `__imp_get_driver_instance' defined in .idata$5 section in C:\Program Files\MySQL\Connector.C++1.1\lib\opt\static/mysqlcppconn.lib(mysqlcppconn.dll.b) "


i have already tried adding -fPIC and -mcmodel=medium/large to compiler
and _mcmodel=medium/large and -dynamic to the linker.
Didnt have any success with these


Any help as to how can i resolve this error?
Viewing all 529 articles
Browse latest View live


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