Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- std::string _dbConnString = "host=" + host + ";user=" + user + ";password=" + password + ";db="+db
- +";compress=true;auto-reconnect=true";
- std::string getkey(int userID, int exchangeID) {
- Poco::Data::MySQL::Connector::registerConnector();
- std::string key;
- {
- // 0. connect & create table
- Session session(Poco::Data::MySQL::Connector::KEY, "host=" + host + ";user=" + user + ";password=" + password +";db=" + db);
- Statement selectn(session);
- selectn << "SELECT key FROM API WHERE user_id=? ", into(api_key), use(userID), now;
- }
- catch (const Poco::Data::ConnectionFailedException &ce)
- {
- std::cout << ce.displayText() << std::endl;
- }
- catch (const Poco::Data::MySQL::StatementException &se)
- {
- std::cout << se.displayText() << std::endl;
- }
- Poco::Data::MySQL::Connector::unregisterConnector();
- return key;
- }
- std::string getuser(int userID, int exchangeID) {
- Poco::Data::MySQL::Connector::registerConnector();
- std::string user;
- try
- {
- // 0. connect & create table
- Session session(Poco::Data::MySQL::Connector::KEY, "host=" + host + ";user=" + user + ";password=" + password +";db=" + db);
- Statement selectn(session);
- selectn << "SELECT user FROM API WHERE user_id=? ", into(user), use(userID), now;
- }
- catch (const Poco::Data::ConnectionFailedException &ce)
- {
- std::cout << ce.displayText() << std::endl;
- }
- catch (const Poco::Data::MySQL::StatementException &se)
- {
- std::cout << se.displayText() << std::endl;
- }
- Poco::Data::MySQL::Connector::unregisterConnector();
- return user;
- }
- std::string key = getkey(user_id,exchange_id); //no error
- std::string user = getuser(user_id,exchange_id); //segmentation fault
- std::string user = getuser(user_id,exchange_id); //no error
- std::string key = getkey(user_id,exchange_id); //segmentation fault
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement