title: Interfacing cassandra with JDBC getting odd hex
body: <p>Im inserting data with hector and getting it back with JDBC.</p>
  
  <p>The data makes no sence apart from the indexed column, im aware that this is because cassandra stores data as bytes and then converts it when its read (client converts it)</p>
  
  <p>Does anyone know how to do this in JDBC for cassandra ?.</p>
  
  <p>My code:</p>
  
  <pre><code>public static void main(String[] args) throws SQLException
      {
          Connection con = null;
          String _KS = "StringMsg";
          String _CFDef = "Tweets";
  
          try 
          {
              Class.forName("org.apache.cassandra.cql.jdbc.CassandraDriver");
              con = DriverManager.getConnection("jdbc:cassandra://localhost:9160/" + _KS);
  
              String query = "SELECT username, email, msg, id FROM " + _CFDef + " WHERE 'username'='LTodorov'";
  
              Statement stmt = con.createStatement();
              ResultSet result = stmt.executeQuery(query);
  
              System.out.println("hi");
              int i=0;
              while (result.next())
              {
                  System.out.println(result.getString("id"));
                  System.out.println(result.getString("username"));
                  System.out.println(result.getString("msg"));
                  System.out.println(result.getString("email"));
                  System.out.print("count:" + i + "\n\n");i++;
              }
          } 
          catch (ClassNotFoundException e) {
              e.printStackTrace();
          }
          catch (SQLException e) {
              e.printStackTrace();
          }
          finally 
          {
              if (con != null) 
              {
                  try 
                  {
                      con.close();
                  } 
                  catch (SQLException e) 
                  {
                      e.printStackTrace();
                  }
                  con = null;
              }
          }
      }
  </code></pre>
  
  <p>Results:</p>
  
  <pre><code>hi
  java.nio.HeapByteBuffer[pos=237 lim=258 cap=798]
  LTodorov
  java.nio.HeapByteBuffer[pos=184 lim=209 cap=798]
  java.nio.HeapByteBuffer[pos=144 lim=155 cap=798]
  count:0
  </code></pre>
  
  <p>Cli Result:</p>
  
  <pre><code>GET Tweets Where username=LTodorov;
  -------------------
  RowKey: LTodorov1330045080096
  =&gt; (column=email, value=6c5f6c74404162762e6267, timestamp=1330045080214000)
  =&gt; (column=id, value=4c546f646f726f7631333330303435303830303936, timestamp=13300
  45080098000)
  =&gt; (column=msg, value=54686973206973206d616b696e67206d652073616466616365, timest
  amp=1330045080210000)
  =&gt; (column=username, value=LTodorov, timestamp=1330045080217000)
  </code></pre>
  
  <p>Cli Result with "assume Tweets validator as utf8";</p>
  
  <pre><code>RowKey: LTodorov1330045080096
  =&gt; (column=email, value=l_ld@Abv.bg, timestamp=1330045080214000)
  =&gt; (column=id, value=LTodorov1330045080096, timestamp=1330045080098000)
  =&gt; (column=msg, value=This is making me sadface, timestamp=1330045080210000)
  =&gt; (column=username, value=LTodorov, timestamp=1330045080217000)
  </code></pre>
  
  <p>Column Family Definition:</p>
  
  <pre><code>CREATE COLUMN FAMILY Tweets
  WITH comparator = UTF8Type
  AND key_validation_class=UTF8Type
  AND column_metadata = [
  {column_name: id, validation_class: UTF8Type}
  {column_name: email, validation_class: UTF8Type}
  {column_name: msg, validation_class: UTF8Type}
  {column_name: user, validation_class: UTF8Type}
  </code></pre>
  
  <p>Any cassandra gurus got any pointers? I'm getting the data back but should it be converted inside java, or should the JDBC api do the work or is it a cassandra thing ? (i think this cant be solved by cassandra) </p>