Overview
Features
Download
Documentation
Community
Add-Ons & Services

Poco and MySQL on linux

Please post support and help requests here.

Poco and MySQL on linux

Postby gtbasher » 15 Sep 2012, 14:28

Hi there,

I have started using Poco for the first time, and I love it!

I have a problem with MySQL.

Code: Select all
#include <Poco/SharedPtr.h>
#include <Poco/Data/SessionFactory.h>
#include <Poco/Data/Session.h>
#include <Poco/Data/MySQL/Connector.h>
#include <vector>
#include <iostream>

using namespace Poco::Data;

void data()
{
   MySQL::Connector::registerConnector();
   Session session("MySQL","some_db");
   MySQL::Connector::unregisterConnector();
}


When I run the pgoram (I'm on openSUSE 11.4) I get the following output:

Code: Select all
terminate called after throwing an instance of 'Poco::Data::MySQL::MySQLException'
  what():  MySQL
Aborted


I have checked and mysql-connector-c++ is installed as rpm -ql shows:

Code: Select all
rpm -ql mysql-connector-c++
/usr
/usr/ANNOUNCEMENT
/usr/COPYING
/usr/INSTALL
/usr/Licenses_for_Third-Party_Components.txt
/usr/README
/usr/include
/usr/include/cppconn
/usr/include/cppconn/build_config.h
/usr/include/cppconn/config.h
/usr/include/cppconn/connection.h
/usr/include/cppconn/datatype.h
/usr/include/cppconn/driver.h
/usr/include/cppconn/exception.h
/usr/include/cppconn/metadata.h
/usr/include/cppconn/parameter_metadata.h
/usr/include/cppconn/prepared_statement.h
/usr/include/cppconn/resultset.h
/usr/include/cppconn/resultset_metadata.h
/usr/include/cppconn/sqlstring.h
/usr/include/cppconn/statement.h
/usr/include/cppconn/warning.h
/usr/include/mysql_connection.h
/usr/include/mysql_driver.h
/usr/lib
/usr/lib/libmysqlcppconn-static.a
/usr/lib/libmysqlcppconn.so
/usr/lib/libmysqlcppconn.so.6
/usr/lib/libmysqlcppconn.so.6.1.1.1


and the databases do exist in /var/lib/mysql.

Hope you can help. Thanks!
gtbasher
 
Posts: 8
Joined: 15 Sep 2012, 14:23

Re: Poco and MySQL on linux

Postby guenter » 15 Sep 2012, 19:40

You'll have to provide a valid MySQL connection string to the Session constructor as second argument. See http://www.connectionstrings.com/mysql for how to create MySQL connection strings.
guenter
 
Posts: 1107
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: Poco and MySQL on linux

Postby gtbasher » 15 Sep 2012, 19:57

Hi guenter,

Thanks for pointing that out, I have no experience with database programming so this stuff is not always obvious to me!
gtbasher
 
Posts: 8
Joined: 15 Sep 2012, 14:23

Re: Poco and MySQL on linux

Postby gtbasher » 15 Sep 2012, 19:58

Hi, is there any chance there will be a database slide coming soon? I found those very informative, and was a good way to find out some details about the other libraries without having much prior experience.
gtbasher
 
Posts: 8
Joined: 15 Sep 2012, 14:23

Re: Poco and MySQL on linux

Postby alex » 17 Sep 2012, 01:39

guenter wrote:You'll have to provide a valid MySQL connection string to the Session constructor as second argument. See http://www.connectionstrings.com/mysql for how to create MySQL connection strings.

Actually, our mysql back-end expects a custom connection string (which probably wasn't the best idea) that looks like this:
Code: Select all
host=YOUR_HOST;port=YOUR_PORT;user=YOUR_USERNAME;password=YOUR_PASSWORD;db=YOUR_DB;compress=true;auto-reconnect=true

See SessionImpl for details.
alex
 
Posts: 1086
Joined: 11 Jul 2006, 16:27
Location: United_States


Return to Support

Who is online

Users browsing this forum: No registered users and 1 guest

cron