mysql - why does this output hex rather than a sentence? connector/c++ -


i expecting see short english sentence output see hex value of instread. cannot find information on getblob function hear should used varchar columns. before used getstring , crashes app, funny though becuase crashes after prints sentence sometimes. cant have crashing need make work getblob, returns std::istream no nothing about. experimented converting istream string lack of understanding of isteam did not me far.

#include <iostream> #include <sstream> #include <memory> #include <string> #include <stdexcept>  #include "cppconn\driver.h" #include "cppconn\connection.h" #include "cppconn\statement.h" #include "cppconn\prepared_statement.h" #include "cppconn\resultset.h" #include "cppconn\metadata.h" #include "cppconn\resultset_metadata.h" #include "cppconn\exception.h" #include "cppconn\warning.h" #include "cppconn\datatype.h"    #include "cppconn\parameter_metadata.h" #include "mysql_connection.h" #include "mysql_driver.h"  using namespace std;   int main() {     sql::mysql::mysql_driver *driver;     sql::connection *con;     sql::statement *stmt;      // ...     driver = sql::mysql::get_mysql_driver_instance();     cout<<"connecting database...\n"; con = driver->connect("tcp://xx.xxx.xxx.xxx:3306", "xxxxx", "xxxxxx");   sql::resultset *res; // ... stmt = con->createstatement(); // ...  con->setschema("mrhowtos_main"); res = stmt->executequery("select english `eng` `id` = 16;"); while (res->next()) {       istream *stream = res->getblob(1);        string s;      getline(*stream, s); //crashes here - access violation     cout << s << endl;  } cout<<"done\n"; delete res; delete stmt; delete con; system("pause");     return 0; } 

update: crashes on getline

value of stream after getblob:

  • stream 0x005f3e88 {_chcount=26806164129143632 } std::basic_istream > *

(this answered first version of question, had cout << stream << endl; statement.)


you're printing istream *.

i suppose read istream , print read, e.g. with

string s;  while (getline(*stream, s))   cout << s << endl;  

Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -