title: Retrieve blob field from mySQL database with MATLAB
body: <p>I'm accessing public mySQL database using JDBC and <a href="http://www.mysql.com/downloads/connector/j/" rel="nofollow noreferrer">mySQL java connector</a>. exonCount is int(10), exonStarts and exonEnds are <strong>longblob</strong> fields.</p>
  
  <pre><code>javaaddpath('mysql-connector-java-5.1.12-bin.jar')
  host = 'genome-mysql.cse.ucsc.edu';
  user = 'genome';
  password = '';
  dbName = 'hg18'; 
  jdbcString = sprintf('jdbc:mysql://%s/%s', host, dbName);
  jdbcDriver = 'com.mysql.jdbc.Driver';
  dbConn = database(dbName, user , password, jdbcDriver, jdbcString);
  gene.Symb = 'CDKN2B';
  % Check to make sure that we successfully connected
  if isconnection(dbConn)
      qry = sprintf('SELECT exonCount, exonStarts, exonEnds FROM refFlat WHERE geneName=''%s''',gene.Symb);
      result = get(fetch(exec(dbConn, qry)), 'Data');
      fprintf('Connection failed: %s\n', dbConn.Message);
  end
  </code></pre>
  
  <p>Here is the result:</p>
  
  <pre><code>result = 
      [2]    [18x1 int8]    [18x1 int8]
      [2]    [18x1 int8]    [18x1 int8]
  
  result{1,2}'
  ans =
     50   49   57   57   50   57   48   49   44   50   49   57   57   56   54   55   51   44
  </code></pre>
  
  <p>This is wrong. The length of vectors in 2nd and 3rd columns should match the numbers in the 1st column.</p>
  
  <p>The 1st blob, for example, should be <code>[21992901; 21998673]</code>. How I can convert it?</p>
  
  <hr>
  
  <p><strong>Update:</strong></p>
  
  <p>Just after submitting this question I thought it might be hex representation of a string.
  And it was confirmed:</p>
  
  <pre><code>&gt;&gt; char(result{1,2}')
  ans =
  21992901,21998673,
  </code></pre>
  
  <p>So now I need to convert all blobs hex data into numeric vectors. Still thinking to do it in a vectorized way, since number of rows can be large.</p>