title: ResultSet.getBlob() Exception
body: <p>The Code:</p>
  
  <pre><code>ResultSet rs = null;
  
  try { 
      conn = getConnection();
      stmt = conn.prepareStatement(sql);
      rs = stmt.executeQuery();
  
      while (rs.next()) {
          Blob blob = rs.getBlob("text");
          byte[] blobbytes = blob.getBytes(1, (int) blob.length());
      String text = new String(blobbytes);
  </code></pre>
  
  <p>The result:</p>
  
  <pre><code>java.sql.SQLException: Invalid column type: getBLOB not implemented for class oracle.jdbc.driver.T4CClobAccessor
  at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:111)
  at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:145)
  at oracle.jdbc.driver.Accessor.unimpl(Accessor.java:357)
  at oracle.jdbc.driver.Accessor.getBLOB(Accessor.java:1299)
  at oracle.jdbc.driver.OracleResultSetImpl.getBLOB(OracleResultSetImpl.java:1280)
  at oracle.jdbc.driver.OracleResultSetImpl.getBlob(OracleResultSetImpl.java:1466)
  at oracle.jdbc.driver.OracleResultSet.getBlob(OracleResultSet.java:1978)
  </code></pre>
  
  <p>I have class12_10g.zip in my class path. I've googled and have found essentially only one site on this particular problem, and it wasn't helpful at.</p>
  
  <p>Does anyone have any ideas on this?</p>
  
  <hr>
  
  <p>A little background:
  We were converting one of our databases from MySQL to Oracle. Within the MySQL DB, one of the fields is a longtext which is treated as a BLOB in the code. The SQL developer workbench by default converts longtext to CLOB (make sense to me) but the code was expecting Blob. I guess the error wasn't that nice: oracle.jdbc.driver.T4CClobAccessor (though it does mention Clob).</p>
  
  <p>When I tried the following:</p>
  
  <pre><code>rs = stmt.executeQuery();
  
  while (rs.next()) {
     byte[] blobbytes = rs.getBytes("text");
     String text = new String(blobbytes);
  }
  </code></pre>
  
  <p>it threw an unsupported exception - all I had to do in the first place was compare the types in the newly created Oracle DB with what the code was expecting (unfortunately I just assumed they would match).</p>
  
  <p>Sorry guys! Not that I've put much thought into it, now I have to figure out why the original developers used BLOB types for longtext</p>