CachedRowSetImpl and BLOB Field
My Program call a Stored Procedure on MYSQL Server 5.0.
The ResultSet received from the Stored Procedure contain a BLOB Field. The field on the ResultSet can be access without any problem.
I create a CachedRowSet for moving Data (meta) from the Resultset to the CachedRowSet.
Example Code
CachedRowSetImpl ObjectRS = new CachedRowSetImpl();
ObjectRS.populate(rs);
When i try to access the BLOB Field from the CachedRowSet, it generated an exception Data Type Mismatch.
I test it with java 1.5 and 1.6 with the same results.
Any Subjection, why it happen the Data Type Mismatch?
[634 byte] By [
BlackHolea] at [2007-11-26 16:00:36]

# 1
BLOB stands for binary Large object. So, the data could (in most be RDBMS implementations) be 2gb or larger. So, 'caching' this data is probably not a good idea in the first place, which is my guess why the driver is politely complaining to you the design is flawed.- Saish
# 3
Yes, the size of a BLOB can be limited programmatically. However, I was simply saying that if I were to code a CachedRowSetImpl, I would not allow LOB's in general if they were cached in memory. I would only allow LOB's if they could be reliably serialized and deserialized from the filesystem. My guess is Sun did the same. Though, I have been unsuccessful getting the source of CachedRowSetImpl, so it is hard to say definitely.
- Saish
# 4
Here include the Class definition i am using for holding the CachedRowSet.
/*
* ObjCacheRowSet.java
*
* Created on January 24, 2007, 1:27 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package TestCRS;
import java.sql.*;
import com.sun.rowset.CachedRowSetImpl;
/**
*
* @author UpdateCom
*/
public class ObjCacheRowSet
{
private CachedRowSetImplObjectRS;
/** Creates a new instance of ObjCacheRowSet */
public ObjCacheRowSet()
{
}
public void load (ResultSet rs)
{
try
{
ObjectRS = new CachedRowSetImpl();
ObjectRS.populate(rs);
}
catch (Exception e)
{
System.out.printf (" Object Name %s Method %s Error %s ", "ObjRef" , "Add-RS",e.getMessage());
}
}
public CachedRowSetImpl toCacheRowSet()
{
return ObjectRS;
}
}
If A ResultSet is load to the object and it contain a BLOB Field, both blob field in the result set as well on the CacheRowSet will contain the same size. But the Blob field in the ResultSet can be converted back to a image, but in the case of the CacheRowSet it generate an exception.
-- Angel