• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Reading InputStream - ExtendedIOException

 
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there. I have some data stored in a DB2 database as a BLOB data type. I am retrieving this data from the database and putting it into an ArrayList as an InputStream object.

I then loop through the ArrayList of InputStream objects to output the images to a JTextPane.
This is the code I am using to insert the images:


However when it tries to execute the "while (is.read(buffer) > 0)"
it returns the following exception:

com.ibm.as400.access.ExtendedIOException: Resource not available.
at com.ibm.as400.access.AS400JDBCInputStream.read(AS400JDBCInputStream.java:201)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read1(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at java.io.FilterInputStream.read(Unknown Source)

I can't seem to figure out exactly what is the issue here? Any ideas?
Thanks for any help!
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
byte[] buffer = new byte[1];
BufferedInputStream is = new BufferedInputStream(imageIS);


To start, you only nominated 1 byte worth to have on the array, images are generally composed of more than one byte.

Look at the API docs for the construction call for BufferedInputStream , because for what your doing
my memory is there is a declaration system for what your trying to do thatgose more like this

byte[] buffer; // is declared as nominated for the BufferedInputStream
streambuffer = new BufferedInputStream(buffer);
while(streambuffer.read(A BYTE)).....
 
Samuel March
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From much wondering exactly how those streams logically come about! , here is something to look through.

 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jennifer Sohl wrote:Hi there. I have some data stored in a DB2 database as a BLOB data type. I am retrieving this data from the database and putting it into an ArrayList as an InputStream object.

I then loop through the ArrayList of InputStream objects to output the images to a JTextPane.
This is the code I am using to insert the images:

However when it tries to execute the "while (is.read(buffer) > 0)"
it returns the following exception:

com.ibm.as400.access.ExtendedIOException: Resource not available.
at com.ibm.as400.access.AS400JDBCInputStream.read(AS400JDBCInputStream.java:201)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read1(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at java.io.FilterInputStream.read(Unknown Source)



InputStream imageIS is not available. Either the driver version you are using could not return an input stream for your BLOB data or the stream is closed before it reaches your method may be because you close your database connection.
 
What do you have to say for yourself? Hmmm? Anything? And you call yourself a tiny ad.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic