To be more specific, it dies at the line

    AutoPtr <Poco::Data::SessionImpl> pSess = conn.createSession(conn_str);

Best regards,
Viet.

On Thu, Oct 23, 2008 at 7:44 PM, Viet Le <viet.aikidorb@gmail.com> wrote:
Hi,

I'm struggling with MySQL (version 1.3.3p1). It always throws incomprehensible exception:

terminate called after throwing an instance of 'Poco::Data::MySQL::MySQLException'
  what():  MySQL
Abort trap

Please kindly assist. Thank you in advance!

Best regards,
Viet.

P.S: And the piece of code is:

#include <iostream>
#include <iostream>
#include <iomanip>

#include <Poco/AutoPtr.h>
#include <Poco/SharedPtr.h>
#include <Poco/Data/SessionFactory.h>
#include <Poco/Data/Session.h>
#include <Poco/Data/RecordSet.h>
#include <Poco/Data/MySQL/MySQL.h>
#include <Poco/Data/MySQL/Binder.h>
#include <Poco/Data/MySQL/Connector.h>
#include <Poco/Data/MySQL/Extractor.h>
#include <Poco/Data/MySQL/MySQLException.h>
#include <Poco/Data/MySQL/MySQLStatementImpl.h>

struct FullEntry {
    unsigned int id;
    std::string title;
    std::string body;
    unsigned char active;
    std::string created_at;
    std::string updated_at;
};

struct Entry {
    unsigned int id;
    std::string title;
    std::string body;
};

using namespace std;

using namespace Poco;
using namespace Poco::Data;
using namespace Poco::Data::MySQL;

int main(int argc, char** argv)
{
    MySQL::Connector::Connector conn;
    MySQL::Connector::registerConnector();
   
    const string conn_str = "host=localhost;port=3306;user=simbre;password=my_simbre;db=simbre;";
    AutoPtr <Poco::Data::SessionImpl> pSess = conn.createSession(conn_str);
    cout << pSess->isConnected() << endl;
   
    Session session(SessionFactory::instance().create(MySQL::Connector::KEY, conn_str));
   
    Statement select(session);
    Entry entry;
    select << "SELECT id, title, body FROM entry ORDER BY id",
        into(entry.id),
        into(entry.title),
        into(entry.body),
        range(0, 1); //  iterate over result set one row at a time
       
    while ( ! select.done() ) {
        select.execute();
        std::cout << std::setw(15) << entry.id << std::setw(15) << entry.title << std::setw(4) << entry.body << std::endl;
    };
   
    return 0;
}


--
I submit to you that if a man hasn't discovered something he will die for, he isn't fit to live.
(Martin Luther King Jr.)
-----



--
I submit to you that if a man hasn't discovered something he will die for, he isn't fit to live.
(Martin Luther King Jr.)
-----