commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Manuel" <man...@ilch.de>
Subject [DBUTILS] BeanHandler plus Blob
Date Fri, 15 Oct 2010 07:06:38 GMT
Hi,

have a class

public class Person {
  private Blob image;
  public void setImage(Blob image) { this.image = image; }
  public Blob getImage() { return image; }
}

Now I want to load the Person-class with BeanHandler-class
ResultSetHandler<Person> h = new BeanHandler<Person>(Person.class);
Person person = runner.query("select image from ...", h);

Works so far :-) Now what not works:

person.getImage();
ObjectInputStream ois = null;
ois = new ObjectInputStream(blob.getBinaryStream());
ImageIcon icon = (ImageIcon) ois.readObject();

-> Exception
You cannot invoke other java.sql.Clob/java.sql.Blob methods after calling
the free() method or after the Blob/Clob's transaction has been committed
or rolled back.

Do the query myself, or and write a own BeanHandler...
But shouldn't there a solution to just say
1.) write blob data in a stream x
2.) write blob data to an object x

OR ... go the other way, means change Person class to have an object let's
say instead Blob and ImageIcon and tell dbutils how to map from blob to
ImageIcon...

thanks for any response in advance ;)

greetings manuel


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message