• 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

BLOB Question - Any Java Guru out there?

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. I have created a table tblRead in Access 2000 with only 1 field:
Field name: Notes
Field type: OLE Object (BLOB equivalent in Access)
2. I have a Java app - something like this:
ResultSet rs = stmt.executeQuery("select Notes from tblRead");
Blob data = rs.getBlob("Notes");
java.io.InputStream in = data.getBinaryStream();
int i;
while ((in.read()) > -1) {
i = in.read();
System.out.println(i);
}
Compiles fine. But gives exception: java.lang.UnsupportedOperationException.
Anybody, any idea where it went wrong?
Thanks
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I'm just guessing here... but is it possible that the data you have put as a BLOB has a mime type "text-plain" and you are getting an exception because you are trying to obtain a binary stream. This is just a random guess... I'm not even sure if mime types matter in BLOBS. Anyways hope it helps.
Parag
 
sanz nsgha
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, it's OLE Object type. That's equivalent of BLOB in Access 2000.
 
author
Posts: 621
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also guessing, but the PrintStream might be throwing this exception because you are trying to print binary (byte) data. Generally, if you want to handle text as such, you would use a CLOB type. Try removing the print statement. If this works, then you'll simply have to retreive the data (in the while loop) as byte data and then convert it to character data.
Sean
 
sanz nsgha
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Sean. The exception is thrown at the following point:
Clob c= rs.getClob(1);
or,
Blob b =rs.getBlob(1);
Doesn't reach the printing point at all. I am thinking if this is the driver.
 
Sean MacLean
author
Posts: 621
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What environment are you running this in (i.e. are you using a container's connection pooling etc.) This is starting to sound like an issue I had with bea weblogic jdbc drivers.
Sean
 
sanz nsgha
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sean, this is a java application. Servlets or JSP not used.
 
Sean MacLean
author
Posts: 621
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well....I still have a feeling it has something to do with a confilct in the drivers that you are using (this was the bea issue I mentioned). There are only two things that are different from the what I do (and I do handle CLOBs/BLOBs a lot).
1) I imagine you are resricted due to the OLE, but I generally use a CLOB for character data. I'm sure this is not a revelation to you.
2) I avoid assigning a value to the BLOB by requesting the inputstream directly


Then I use the output stream as desired. I'd be really interested to know the issue when you figure it out. Sorry I couldn't be more help
Sean
 
sanz nsgha
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Sean. Somebody mentioned that it may be due to incompatibility of OLE object in Access (equivalent of Blob) and SQL Blob type in Java/JDBC/SQL. This may need an ODBC driver that supports this. Will let you know if anything new is found.
 
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"java.lang.UnsupportedOperationException"
This means that your driver does not support the method getBlob()/getClob() methods. Try eliminating that middle step (getBlob) by using only
InputStream in = rs.getBinaryStream( 1 );
works for me(JDBC DBC bridge to MSAccess 97).
if your driver does not support this method, then you'll have to find a new one or update your existing driver.
Jamie
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
just an idea do u have any problem retrieving your data from access using just sql command? i had problem once in oracle even though i stored my blobs in the data base but when i retreive them i had problems due to tables set in the db...
reply
    Bookmark Topic Watch Topic
  • New Topic