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

#include Problem! (no replies)

$
0
0
I am using MS VS 2008 and I am developing a program, which shall use MySQL server on another PC. I downloaded the MySQL Connector/C++. I included "mysql_connection.h", but the compiler cannot find "<boost/variant.hpp>".

Pls, help me!

The application was unable to start correctly (1 reply)

$
0
0
I was able to get the program listed here http://dev.mysql.com/doc/refman/5.1/en/connector-cpp-examples-complete-example-1.html to compile and link with VC++ 2012, but the program won't run. Get the error message "The application was unable to start correctly (address here) Click OK to close the application)." I copied libmysql.dll and mysqlcppconn.dll into the same folder as the program executable. I get the same error in both debug and release builds.

I have the MySQL database server running on a different computer than the one I am using to build the application program. I copied libmysql.lib from that other computer so that my program could link. Could that be the problem? I am using the 32-bit version of the server instead of the 64-bit version.

getting segmentation fault in the program (no replies)

$
0
0
I am getting a segmentation fault sometimes in my application(It comes very rarerly, like once in 300 runs of program. Since it doesnt come always so I cant gdb it).

*** Aborted at 1362124211 (unix time) try "date -d @1362124211" if you are using GNU date ***
PC: @ 0x8ae07b my_stat
*** SIGSEGV (@0x0) received by PID 7495 (TID 0x7f0bbfafe700) from PID 0; stack trace: ***
@ 0x7f0bc28edeaf (unknown)
@ 0x8ae07b my_stat
@ 0x8ac4f1 my_read_charset_file
@ 0x8acf08 init_available_charsets
@ 0x7f0bc1dcb952 __pthread_once_internal
@ 0x8ad28c get_charset_by_csname
@ 0x8b990d mysql_init_character_set
@ 0x8ba9fb mysql_real_connect

I am not sure why I am getting this. Any ideas what it means or if I can use this information to reproduce this.

unresolved symbol error MySQL_Driver* (no replies)

$
0
0
Hello;
The second statement causes the error.
I tried all the example codes that are on this site but get the same link error.
If I comment out the second line the program compiles just fine.
Does anyone know what I can do to fix this?
Thank you;
Dean

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

LNK2001: unresolved external symbol "class sql::mysql::MySQL_Driver * __cdecl sql::mysql::get_driver_instance(void)" (?get_driver_instance@mysql@sql@@YAPAVMySQL_Driver@12@X

Tried the examples code and got the same link error.
I am using Visual Studio 2010 Professional and intellisense picks up the members of the classes just fine. There are no errors in the code but the get_driver_instance(); will not link, I wonder if this is a bug?

Program throws error 15 (no replies)

$
0
0
This simple code throws error 15? What does that mean? I can't find the error codes documented anywhere. It's strange because the data gets inserted into the table then throws the exception afterwards.


#include <stdlib.h>
#include <iostream>

/*
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 "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)
{
try {
sql::Driver *driver;
sql::Connection *con;
sql::Statement *stmt;
sql::ResultSet *res;

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

stmt = con->createStatement();
res = stmt->executeQuery("INSERT INTO bung VALUES ('39', 'TestVal')");
delete res;
delete stmt;
delete con;

} catch (sql::SQLException &e) {
cout << e.getErrorCode();
}

cout << endl;

return EXIT_SUCCESS;
}

How to get mysys.lib (no replies)

$
0
0
I have a Visual C++ Project that uses MySQL that I inherited. When I compiled it it gave me this error

error LNK1104: cannot open file 'mysys.lib'

The Linker requires this library. The question from where can I get it?

library that contains mysql_init,mysql_query,mysql_fetch_row etc (1 reply)

$
0
0
I inherited a really old codebase in C++ that is communicating with MySQL database part of which is shown below. The question what library defines functions such as mysql_init and the ones mentioned in the subject line.

MYSQL *hnd=NULL; // mysql connection handle
MYSQL_RES *res=NULL; // result of querying for all rows in table
MYSQL_ROW row; // one row returned

// START :: Get user's and company's profile from Awning Manager's DBs
hnd = mysql_init(NULL);
if (NULL == mysql_real_connect(hnd,DBServerName,DBUsername,DBPassword,"amlicensing",0,NULL,0))
MessageBox (NULL, "problem connecting..\n"
"Please ensure that you're connected to the internet and that your\n"
, "Error", MB_OK|MB_ICONERROR);
else
{
if (!mysql_query(hnd,"select * from users where username=\"" + s_LocalLoggedInAs + "\""))
{
res = mysql_use_result(hnd);
if (res)
{

going back to the jbad (no replies)

$
0
0
Ufc on Fox 11 Werdum vs Browne Live vk.com/ufconfox11livestream

Ufc on Fox 11 Live facebook.com/ufconfox11livestream

game of thrones season 4 episode 3 facebook.com/watchgameofthronesseason4episode3onlinelive

Cannot get started with Visual Studio C++ 2010 (1 reply)

$
0
0
I have been using MySQL with PHP, Python and Perl for a couple of years now. I am not experienced with C++ or any compiled programming at all beyond some basics.

-- Dynamic Versus Static Builds and Other Decisions

I have been reading the Documentation at MySQL on how to install MySQL Connector/C++ and have come against some decisions that I cannot figure out. I am working in XP Pro and using Visual Studio C++ 2010 Express

First, which should I install, the binary or source distribution?

http://dev.mysql.com/doc/connector-cpp/en/connector-cpp-downloading.html

If this were just software, I might imagine that it was just a question of installing a compiled program over compiling my own version. But these are themselves to be applied in computer programs, I don't understand the difference. What good are binaries. Don't I need libraries of code? Why do I need binaries to write programs? Won't I be compiling my own code?

I have tried installing Connector/C++ from the MSI installer and running programs as described in the tutorials and I keep getting errors. Should I be installing from source like here?

http://dev.mysql.com/doc/connector-cpp/en/connector-cpp-installation-source-windows.html

The next thing I don't understand is the difference between a "static build" and a "dynamic build". I don't see anything in Visual Studio that looks like this is an option. How do I decide whether I want to build statically or dynamically and how do I make this decision in Visual Studio?

Information on "dynamically linking" is here at MySQL:

http://dev.mysql.com/doc/connector-cpp/en/connector-cpp-dynamic-linking-client-library.html

After installing the Connector from the MSI installer I have followed the instructions here

http://dev.mysql.com/doc/connector-cpp/en/connector-cpp-apps-windows-visual-studio.html

and again, I am up against the decision about "static" versus "dynamic" builds. I tried making sure that the settings included both, assuming some option might be available later. And yes, I have installed the boost files and adapted changes appropriate to Visual Studio 2010.

-- I Cannot Get the Examples to Work

I have been able to get this demonstration to work:

http://dev.mysql.com/doc/connector-cpp/en/connector-cpp-tutorials-background.html

But when I try and copy and paste the examples here as instructed,

http://dev.mysql.com/doc/connector-cpp/en/connector-cpp-getting-started-examples.html

they don't work.

What are the missing steps to getting the examples to work in Visual Studio C++ 2010?

fetching string from database (no replies)

$
0
0
Hello anyone. First, please forgive me my bad language then...please help me resolve my problem. I have little chunk of code:

/* INSERT TUTORIAL CODE HERE! */
sql::Driver *driver = get_driver_instance();
std::auto_ptr<sql::Connection> con(driver->connect("tcp://127.0.0.1:3307", "root", "pass"));
con->setSchema("mybase");
std::auto_ptr<sql::Statement> stmt(con->createStatement());

//example from dev/mysql site

stmt->execute("DROP TABLE IF EXISTS mcountry");
stmt->execute("DROP PROCEDURE IF EXISTS add_ctry");
stmt->execute("DROP PROCEDURE IF EXISTS getdata");

stmt->execute("CREATE TABLE mcountry(country_id INT)");
stmt->execute("CREATE PROCEDURE add_ctry(IN cname INT) BEGIN INSERT INTO mcountry(country_name) VALUES (cname); END;");
stmt->execute("CREATE PROCEDURE getdata() BEGIN SELECT * FROM mcountry; END;");

stmt->execute("CALL add_ctry(112)");
stmt->execute("CALL add_ctry(323)");

stmt->execute("CALL getdata()");

std::auto_ptr<sql::ResultSet> res;

do{
res.reset(stmt->getResultSet());
while(res->next())
{
cout << "ID: " << res->getInt(1);
}
} while(stmt->getMoreResults());

This works fine, I get result as expected but when i change type from INT
to CHAR nothing works. I need fetch string data from my table but instead of
good results I get only strange garbage data. Please help me and thanks for any answers

/* INSERT TUTORIAL CODE HERE! */
sql::Driver *driver = get_driver_instance();
std::auto_ptr<sql::Connection> con(driver->connect("tcp://127.0.0.1:3307", "root", "sqlroot.9194"));
con->setSchema("mybase");
std::auto_ptr<sql::Statement> stmt(con->createStatement());

//example from dev/mysql site

stmt->execute("DROP TABLE IF EXISTS mcountry");
stmt->execute("DROP PROCEDURE IF EXISTS add_ctry");
stmt->execute("DROP PROCEDURE IF EXISTS getdata");

stmt->execute("CREATE TABLE mcountry(country_name CHAR(3))");
stmt->execute("CREATE PROCEDURE add_ctry(IN cname CHAR(3)) BEGIN INSERT INTO mcountry(country_name) VALUES (cname); END;");
stmt->execute("CREATE PROCEDURE getdata() BEGIN SELECT * FROM mcountry; END;");

stmt->execute("CALL add_ctry('abc')");
stmt->execute("CALL add_ctry('def')");

stmt->execute("CALL getdata()");

std::auto_ptr<sql::ResultSet> res;

do{
res.reset(stmt->getResultSet());
while(res->next())
{
cout << "Name: " << res->getString(1);
}
} while(stmt->getMoreResults());

MySQL C++ Connector crashes executing INSERT with BLOB (no replies)

$
0
0
I've stuck with a problem, trying to insert text as blob value, MySQL C++ connector crashed with exception: "Access violation reading location". I've seen questions like this here, but none has been answered. Here is a code sample:

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

#include <string>
#include <iostream>
#include <sstream>

using namespace sql;

void main(){
Connection *dbConnection;
Driver *driver;
Connection *con;

driver = get_driver_instance();
con = driver->connect("localhost", "root", "");
Statement *stmt = con->createStatement();
try{
stmt->execute("USE test");
stmt->execute("DROP TABLE blob_test");
stmt->execute("CREATE TABLE blob_test("
"id INTEGER PRIMARY KEY NOT NULL AUTO_INCREMENT,"
"original BLOB NOT NULL);");
char smallBlob[32];

for (char i = 0; i < sizeof(smallBlob); ++i)
{
smallBlob = i;
}
std::istringstream str(smallBlob);
PreparedStatement *pstmt = con->prepareStatement("INSERT INTO blob_test(id, original) VALUES (1, ?)");

pstmt->setBlob( 1, &str);
pstmt->executeUpdate();
}catch(sql::SQLException &e){
std::cerr << "# ERR: " << e.what();
std::cerr << " (MySQL error code: " << e.getErrorCode();
std::cerr << ", SQLState: " << e.getSQLState() << " )" << std::endl;
}
}

Thanks in advance!

command out of sync (no replies)

$
0
0
I use C++ connector to connection with MYSQL.But when I want to execute two query in one connection ,It tell me command out of sync.I didn't use auto_ptr like connection document.This is my code:

pstmt = conn->preparedStatement("Call a(?)");
....
res = pstmt->executeQuery();
..
delete res;
delete pstmt;
pstmt = conn->preparedStatement("Call b(?)");
//ERROR:It tells me Commands out of sync.

why I can't execute it?Can you give me a right way to do it .

How to install c++ connector on CentOS release 6.5? (no replies)

$
0
0
Is there an easy way to install c++ connector on CentOS release 6.5.
I've been looking through a lot of topics over the internet and nothing is very helpfull.

I need an easy way like an executable that runs the whole thing.

thanks...

libmysqlcppconn.so.5: cannot open shared object file: No such file or directory (no replies)

$
0
0
I built a simple c++ application using Netbeans on ubuntu. in the application I use mysql_connection and curl. the application is working fine on my local system (Ubuntu)

when I tried to run the application on my Centos server I get this message:

error while loading shared libraries: libmysqlcppconn.so.5: cannot open shared object file: No such file or directory.

tried to check if the libmysqlcppconn.so.5 library exists on the server or not I found that there is the following:

REMOTE (Centos)
**in [/usr/local/lib]**

libmysqlcppconn-static.a
libmysqlcppconn.so@
libmysqlcppconn.so.7@
libmysqlcppconn.so.7.1.1.3*


LOCAL (Ubuntu)
**in [/usr/lib]**

libmysqlcppconn-static.a
libmysqlcppconn.so@
libmysqlcppconn.so.5@
libmysqlcppconn.so.5.1.1.0*

why can't the application run? How can I fix it?

PreparedStatement can't work? (no replies)

$
0
0
Hi all, I am a new comer for mysql connector/c++ user. The PreparedStatement can't working in my project, but statement was fine. I had search so much time but no result for it.

Version: mysql 5.0.18, connector c++, 1.0.5

Database table struct:
table name : city,
name varchar(20)
country varchar(20)

code:

pstmt=con->prepareStatement("insert into city(name, country) values(?,?)");
pstmt->setString(1, "Beijing1");
pstmt->setString(2, "China2");
//pstmt->execute();
pstmt->executeUpdate();

after running, a record which name is 0, country is NULL will be inserted into city.

Who can explain it for me, Thanks.

Run connector on Vxworks? (no replies)

$
0
0
Have anyone tried to run the C connector on the Vxworks? Is it possible?

missing libmysql.lib file (1 reply)

$
0
0
I've set up everything as I should for vs 2012, I even have boost linked, but I got this LNK 1181 error for libmysql.lib. Why is this erro happening and how do I fix it?

Use mysql++, get a resultset with 10000 rows and iterate the resultset (no replies)

$
0
0
I use mysql++, get a resultset and iterate it like this:

Query qr = conn->query(sql);
UseQueryResult res = qr.use();

while(Row row = res.fetch_row())
{
}

The resultset has 10000 rows,this "While" Loop took 3.5 seconds.
is this situation normal? I thought it should completed much faster!

mysql connector C++ with VS 2012 (no replies)

$
0
0
Hi, I have been trying to use mysql connector C++ with my application on Visual Studio 2012, I have followed the tutorial on mysql website step by step to statically link, I have added all the libraries and includes as mentioned in the tutorials, when I try to build the complete example they have I get 33 unresolved external symbol! all generated from mysqlcppconn-static.lib, one of them is as follow:
//////////////////////////////////////////////////
1>mysqlcppconn-static.lib(mysql_art_resultset.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z)
////////////////////////////////////////////////////

anyone can assist me to resolve this issue, thank you

Deploying C++ Connector to linux. Painful or not? (no replies)

$
0
0
Hello,

I just started using C++ connector, but I must admit, that the deploying it under Visual Studio 2013 was a really painful experience. (The package with built binaries didn't work due it being linked against MSVCP90D and MSVCR90D which are debug libraries) so I had to build it myself. Which wasn't exactly as easy I expected either (errors).

The problem is, that at some point the application will need to be built under linux. If the process of deploying the package on linux is as counterproductive as on Windows MSVC, then it might be easier for me to just write my own simple C++ wrapper and use raw MySQL C API.
I mean look at the boost libraries. Building them is as simple as setting OpenSSL and Zlib paths (which is optional anyways) and running a build script.

So again - the question is: Is it actually easier to deploy this cursed package on linux? Or there are tons of troubles too?

Thank you for your answers,

John
Viewing all 529 articles
Browse latest View live


Latest Images

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