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

Will this work with mysql (from Red Had Portal) (no replies)

$
0
0
Hello,
I am trying get Connector-c++ to work on a Rhel 6 system that currently has MySQL installed via rmp downloaded from the Red Had customer portal. The rpms currently installed are:

mysql-5.1.73-8.el6_8.x86_64
MySQL-devel...
MySQL-server...
MySQL-libs...

I started to try and find a corresponding rpm between what is offered on the Rhel site and what is in the community bundle, but couldn't. For example, there is no MySQL-client-5.1.73-8.el6_8.x86_64.rpm on the Rhel site.

So, my question is... Is there a way to get Connector-c++ to work on my existing system, or do I have to remove the old MySQL and install the community version?

Thanks,
Jeff.

undefined reference for some functions (no replies)

$
0
0
Dear friends,

The following functios are declared in the mysql.h header file that is well included in the example source code. And it´s path well seted.

But the compiler says:

undefined reference to 'mysql_real_connect'
undefined reference to 'mysql_query'
undefined reference to 'mysql_store_result'
undefined reference to 'mysql_num_rows'
undefined reference to 'mysql_fetch_row'
undefined reference to 'mysql_close'

Could you helpe me please?

Thanks in advance.

C1083 Cannot open include file cppconn/connection.h (no replies)

$
0
0
Help! I get the following C1083 error:
"Cannot open include file: 'cppconn/connection.h': No such file or directory.'

I am using VS2015. I have read C1083 but cannot get this fatal error corrected.

I am probably doing something stupid. Can someone help?

Here's the code entered.

// example.cpp : Defines the entry point for the console application.
//

/* Standard C++ includes */
#include "stdafx.h"
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <stdexcept>


/*
Include directly the different
headers from cppconn/ and mysql_driver.h + mysql_util.h
(and mysql_connection.h). This will reduce your build time!
*/
#include "C:/Program Files/MySQL/Connector.C++ 1.1/include/mysql_connection.h"

#include "C:/Program Files/MySQL/Connector.C++ 1.1/include/cppconn/connection.h"
#include "C:/Program Files/MySQL/Connector.C++ 1.1/include/cppconn/driver.h"
#include "C:/Program Files/MySQL/Connector.C++ 1.1/include/cppconn/exception.h"
#include "C:/Program Files/MySQL/Connector.C++ 1.1/include/cppconn/resultset.h"
#include "C:/Program Files/MySQL/Connector.C++ 1.1/include/cppconn/statement.h"
#include "C:/Program Files/MySQL/Connector.C++ 1.1/include/cppconn/prepared_statement.h"


using namespace std;

int main(void)
{
cout << endl;
cout << "Let's have MySQL count from 10 to 1..." << endl;


try {
sql::Driver *driver;
sql::Connection *con;
sql::Statement *stmt;
sql::ResultSet *res;
sql::PreparedStatement *pstmt;

/* Create a connection */
driver = get_driver_instance();
con = driver->connect("tcp://127.0.0.1:3306", "root", "root");
/* Connect to the MySQL test database */
con->setSchema("test");

stmt = con->createStatement();
stmt->execute("DROP TABLE IF EXISTS test");
stmt->execute("CREATE TABLE test(id INT)");
delete stmt;

/* '?' is the supported placeholder syntax */

pstmt = con->prepareStatement("INSERT INTO test(id) VALUES (?)");
for (int i = 1; i <= 10; i++) {
pstmt->setInt(1, i);
pstmt->executeUpdate();
}
delete pstmt;

/* Select in ascending order */
pstmt = con->prepareStatement("SELECT id FROM test ORDER BY id ASC");
res = pstmt->executeQuery();

/* Fetch in reverse = descending order! */
res->afterLast();
while (res->previous())
cout << "\t... MySQL counts: " << res->getInt("id") << endl;
delete res;

delete pstmt;
delete con;

}
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;
}

What is mysql command line to show help topics for attributes? (no replies)

$
0
0
Hi,

I ran the help but could not find help contents for attributes to show such as auto increment, not null, etc, but there is no content to show attributes, how would you run help for attributes?

mysql> help attributes;
Nothing found
Please try to run 'help contents' for a list of all accessible topics

mysql> help contents;

MySQL Connector/C++ : Class List/Data Member List/Member Function List (no replies)

$
0
0
I am looking for MySQL Connector/C++ : Class List/Data Member List/Member Function List.
For Eg. :
In ResultSet what Data Member List/Member Function List available.
Is any such documentation available.

Block when query from mysql (no replies)

$
0
0
Our server codes is always blocked like this:
(Thread 0x7f889ffff700 (LWP 128204)):
#0 0x0000000000dc0411 in read () at ../sysdeps/unix/syscall-template.S:82
#1 0x0000000000d620e2 in vio_read_buff ()
#2 0x0000000000d50f11 in my_real_read(st_net*, unsigned long*) ()
#3 0x0000000000d51a58 in my_net_read ()
#4 0x0000000000d4bbba in cli_safe_read ()
#5 0x0000000000d4ccd0 in cli_read_query_result ()
#6 0x0000000000d4db1e in mysql_real_query ()
#7 0x0000000000d406e5 in sql::mysql::MySQL_Statement::do_query (this=0x7f87ed07e040, q=0x7f87ed247288 "select * from CASINOUSERFISHSKILLINFO_2 where userid = 35326854", length=63)
at /game/mysql-connector-c++-1.0.5/driver/mysql_statement.cpp:73
#8 0x0000000000d40a02 in sql::mysql::MySQL_Statement::executeQuery (this=0x7f87ed07e040, sql=...) at /game/mysql-connector-c++-1.0.5/driver/mysql_statement.cpp:127

It happens once in one to two weeks, begins in several months, but it worked well before. And our DBA can't find issue from mysql server, it will be resolved if we restart our own server.

I think it seems to be tcp disconnect but not detected, but not sured and have no method to fix it.

I have tried to add OPT_WRITE_TIMEOUT and OPT_READ_TIMEOUT, but it doesn't work, or I use it wrongly

The OPT_WRITE_TIMEOUT and OPT_READ_TIMEOUT is used like this

std::map<std::string, sql::ConnectPropertyVal> mapConnectionProperties;
mapConnectionProperties["hostName"] = CreateConnectPropertyVal(iter->second);
mapConnectionProperties["userName"] = CreateConnectPropertyVal((i <= 7) ? username1 : username2);
mapConnectionProperties["password"] = CreateConnectPropertyVal((i <= 7) ? password1 : password2);
mapConnectionProperties["OPT_WRITE_TIMEOUT"] = CreateConnectPropertyVal(2);
mapConnectionProperties["OPT_READ_TIMEOUT"] = CreateConnectPropertyVal(2);

function CreateConnectPropertyVal is
ConnectPropertyVal CDBManager::CreateConnectPropertyVal(long long iValue) {
ConnectPropertyVal val;
val.lval = iValue;
return val;
}
Our mysql server version is 5.6.29
libmysqlcppconn version is 1.0.5
Can anyone help me, or anyone has meet the problem before? Thank you very much

VS 2017 Community (no replies)

$
0
0
So I have been revisiting C++ and started back using VS 2017 Community. So I decided to step out and try to connect to MySQL. Wow, this was not like using C# to setup.

So I followed the instructions downloaded Boost 1.65 and worked my way through the instructions to setup my project so that I could (hopefully) use MySQL in upcoming C++ projects.

So the first question I have is that it will not run and I haven't even tried to 'do' anything yet:

#include <iostream>
#include <mysql_connection.h>
#include <mysql_driver.h>
#include <mysql_error.h>

using namespace std;

void main() {
// create a connection
sql::mysql::MySQL_Driver *driver;
sql::Connection *con;

driver = sql::mysql::get_mysql_driver_instance();


system("PAUSE");
}

yields an intimidating list of errors starting with a bunch of:
"LINK2038 mismatch detected for '_MSC_VER': value '1800' doesn't match value '1900' in tester.obj (for MySQL_driver.obj on through a litany of other obj files)

The other question or concern I have is if I even get this working, will my users have to go through and install all of these dependencies as well or will I be able to deploy / copy the dll file for MySQL connector? I mean that would really be a tragic user experience.

Could not find dynamic "mysqlclient_r mysqlclient" in MYSQL_LIB_DIR (no replies)

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

$
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++ ? (1 reply)

$
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

Run multiple update / select from one query (1 reply)

$
0
0
Hi,

I need a query command to update multiple rows to set the alertState (char(1) to true if any tables match following conditions:

- the last contact time < now - timeout
- the the alertState = false

I tried following command, but it got syntax problems:

update Device set alertState = 1 where (select alertState, lastContact from Device where lastContact < 1511751383) and alertState = 0;

ERROR 1241 (21000): Operand should contain 1 column(s)

Also, is it possible to update multiple rows in one query?

Thank you.

Update and insert in one query (no replies)

$
0
0
Hi,

I want to update one table and insert to another table in one query, but the insert command cannot see the statement.id from the update. Appreciate clues

update Device, (select id, alertState, lastContact from Device where lastContact < 1511765116 and alertState = 0) as statement set Device.alertState = 1 where Device.id = statement.id; insert Alert (DeviceId, Message) value (statement.id, "Alert");

Thank you.

Kind regards,

Dealing with date and time fields (no replies)

$
0
0
I'm probably missing something very trivial, but I'm stumped. I'm using a C++ connector to read data from Mysql. Basic strings and ints are fine. But the sql::ResultSet does not have the getTime() method that's documented. So I can't access date/time fields from Mysql.

I looked at the cppconn/resultset.h and indeed there is no prototype for getTime().

I installed the cppconn via:
%apt-get install libmysqlcppconn-dev

I also downloaded the source from https://dev.mysql.com/downloads/connector/cpp/ (mysql-connector-c++-1.1.9-linux-debian8-x86-32bit) and the resultset.h is identical (no getTime() prototype).

How to connect MYSQL through SSH tunne BY Connector/C++ (no replies)

$
0
0
I try to connect mysql use Connector/C++ in desktop app(not QT,not C#)
How to connect MYSQL through SSH tunne
thank you!

No createTable() method, how to add a table with X DevAPI (no replies)

$
0
0
The C++ X DevApi has a createCollection(), a dropCollection() and a dropTable() method, yet no createTable() method (the Java X DevAPI has one). Why is that? How are we supposed to add tables?

C++ Connector/Corruption when using Prepared Statement (no replies)

$
0
0
I have been hunting down a memory corruption issue with the results of C++/Connector for the last couple of days.

The issue really only shows up when using a prepared statement, and the resul is of type MYSQL_TYPE_VAR_STRING > 64 bytes in length. In my case the result was 70 characters in length and would get corrupted after the 64th byte.

I have narrowed down the bug to here -
mysql_resultbind.cpp in allocate_buffer_for_field():

case MYSQL_TYPE_VAR_STRING:
#if LIBMYSQL_VERSION_ID > 50700
case MYSQL_TYPE_JSON:
return st_buffer_size_type(new char[field->max_length + 1], field->max_length + 1, field->type);
#endif //LIBMYSQL_VERSION_ID > 50700

For some reason LIBMYSQL_VERSION_ID is not set at all at this point (but MYSQL_VERSION_ID) is. I haven't figured out why its not set yet...

So the switch falls thru to MYSQL_TYPE_DECIMAL and allocates a fixed 64 bytes.
This behavior does not seem correct, why would a VAR_STRING ever fall through to a fixed 64 bytes?

I feel like the return statement should be outside of the #if/#endif and it is a bug having it inside the #if statement.

Can one of the developers elaborate?

C++ devapi_test error (no replies)

$
0
0
Since I built the code from source, I ran devapi_test.exe, but got an error: ERROR: CDK Error: Capability prepare failed for 'tls'. What this means and how to solve it?

C++ Connector Source Build Issues in VS2017 (no replies)

$
0
0
My current developing application is built in VS2017. So I tried to build C++ Connector source in VS2017 to avoid linking issues. I made the build succeed. VS2017 says "35 succeeded, 0 failed, 2 skipped". The c++ connector version is 1.1.9.

I found the lib and dll files under driver/Release. However, the size of dll file is not match with the installed version. In the install version, dll file is 5.7 MB. But in the source compiled version, dll file is 578 KB.

I wrote a simple test to check which one works. The installed version dll works fine, but source compiled version dll does not work. Could you provide suggestion to fix the problem?

Thanks for your help.

Eclipse program crashing when connecting to MySQL Server (no replies)

$
0
0
I am writing a simple program in Eclipse CDT to connect to a MySQL Server hosted locally. I have ensured the server is running. The code I am trying to execute is the following:

  void CMyClass::fnDatabaseConnection(){

  sql::Driver *driver;
  sql::Connection *connection;
  sql::ResultSet *result;
  sql::Statement *statement;
  sql::PreparedStatement *prepared;
  driver = get_driver_instance();

  connection = driver->connect("tcp://127.0.0.1:3306","DBServer","root"); /*Where the program crashes*/

  statement = connection->createStatement();
  statement->execute("SHOW DATABASES");

  delete statement;
  delete connection;
}

The include statements are:

#include <mysql_driver.h>
#include <mysql_connection.h>
#include <stdlib.h>
#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>
#include <cppconn/prepared_statement.h>

The program crashes on running. While debugging I can see that the crash occurs while trying to establish the connection to the server. I have ensured that all required libraries have been added along with the required include files (I have images for the same but am unable to add them here). I am not sure what is it that I am doing wrong.

One of my doubts is the get_driver_instance() function used might from a different library, but adding sql:: or even sql::mysql:: in front of it gives undefined reference errors, even though the libraries have been added.

Here are items that have been included:
[output]
Header Files:
-I
1. "C:\Program Files\MySQL\MySQL Server 5.6\include"
2. "C:\Program Files\MySQL\Connector.C++ 1.1\include"
3. "C:\boost_1_66_0"

-include
1. "C:\Program Files\MySQL\Connector.C++ 1.1\include\mysql_connection.h" (added manually as there was an issue with the compiler finding it)

Libraries:
-L
1. "C:\Program Files\MySQL\MySQL Server 5.6\lib"
2. "C:\Program Files\MySQL\Connector.C++ 1.1\lib\opt"

Miscellaneous ( as they don't follow GCC naming conventions)
1. "C:\Program Files\MySQL\Connector.C++ 1.1\lib\opt\mysqlcppconn-static.lib"
2. "C:\Program Files\MySQL\Connector.C++ 1.1\lib\opt\mysqlcppconn.dll"
3. "C:\Program Files\MySQL\MySQL Server 5.6\lib\mysqlclient.lib"
4. "C:\Program Files\MySQL\MySQL Server 5.6\lib\libmysql.lib"
[/output]
Viewing all 527 articles
Browse latest View live


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