title: How to send query to populate utf8 VARCHAR column using Connector/C++?
body: <p>In my C++ application (On Windows x64 being developed using VS2012) I am using MySQL Connector/C++ to connect MySQL database. I've table ALL_USERNAMES that has a column:</p>
  
  <pre><code>USERNAME VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_unicode_ci
  </code></pre>
  
  <p>However, I am not sure how can I fire utf8 queries through my C++ application. Method <code>sql::Statement::executeUpdate</code> accepts <code>sql::SQLString</code> type. It is essentially <code>std::string</code>.</p>
  
  <p>So if I do something like this:</p>
  
  <pre><code>std::string strQuery = "INSERT INTO ALL_USERNAMES (USERNAME) VALUES ('अतुल')"
  executeUpdate(strQuery);
  </code></pre>
  
  <p>And when I check the table record through MySQL  Workbench I see USERNAME as all question marks (???????).</p>
  
  <p>I couldn't find anything about this in Connector/C++ documentation. Any idea how to solve this?</p>
  
  <p><strong>What I wanted to try:</strong></p>
  
  <p>In MySQL C API there are functions like:</p>
  
  <pre><code>mysql_options(&amp;mysql, MYSQL_SET_CHARSET_NAME, "utf8"); 
  mysql_options(&amp;mysql, MYSQL_INIT_COMMAND, "SET NAMES utf8"); 
  </code></pre>
  
  <p>which I wanted to try as I suspect it will solve my problem. 
  But I couldn't find its counterpart in Connector/C++.</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p><code>SHOW CREATE TABLE</code> gives me this:</p>
  
  <pre><code>'ALL_USERNAMES', 'CREATE TABLE `all_usernames` (\n  `USERNAME` varchar(32) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL\n) ENGINE=InnoDB DEFAULT CHARSET=utf8'
  </code></pre>
  
  <p>And my client code is here (this was before I written my own answer):</p>
  
  <pre><code>sql::Connection *m_pConnection = NULL;
  sql::Statement *m_pStatement = NULL;
  sql::Driver *driver = NULL;
  
  driver = get_driver_instance();
  m_pConnection = driver-&gt;connect("tcp://127.0.0.1:3306", "username", "password");
  m_pConnection-&gt;setSchema("DBNAME");
  m_pStatement = m_pConnection-&gt;createStatement();
  int RetVal = m_pStatement-&gt;executeUpdate("INSERT INTO ALL_USERNAMES (USERNAME) VALUES ('अतुल')");
  </code></pre>