aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes JDBC - BLOB question for Java gurus Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "JDBC - BLOB question for Java gurus" Watch "JDBC - BLOB question for Java gurus" New topic
Author

JDBC - BLOB question for Java gurus

sanz nsgha
Ranch Hand

Joined: Jan 18, 2002
Posts: 42
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
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

Hi Sanjay
When I use the Blob datatype I use this code:

The class ObjectConverter has two methods, one of them is toObject:

/Ren�


Regards, Rene Larsen
Dropbox Invite
sanz nsgha
Ranch Hand

Joined: Jan 18, 2002
Posts: 42
Rene, thanks a lot of your answer.
Debugging shows that an exception occurs at:
Blob readBlob = rs.getBlob(1);
So I am wondering if the problem is non-compatibility of JDBC "Blob" type and Microsoft Access "OLE OBject" type. Have you tried the code with MS Access OLE Object?
Thanks again
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

Hi
No I have not.
Maybe you can use:
Object obj = rs.getObject(1);
and then caste obj to an OLE Object??
/Ren�
sanz nsgha
Ranch Hand

Joined: Jan 18, 2002
Posts: 42
Thanks Rene. What would be the compatible type in MS Access 2000 for Java/JDBC Blob type?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

You might want to post this message in the JDBC forum, as it has no bearing on the SCJD exam.
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
sanz nsgha
Ranch Hand

Joined: Jan 18, 2002
Posts: 42
mark, i don't think so. as a developer preparing for developer exam, we should be able to analyze and troubleshoot such problems.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

mark, i don't think so. as a developer preparing for developer exam, we should be able to analyze and troubleshoot such problems.

What part of the assignment is about JDBC or Access. Nothing, therefore you are wrong. You also posted this in the SCWCD Exam, now again JDBC and Access has nothing to do with the Web Component Cert. Your question only fits into the JDBC Forum, and maybe EJB, if you are creating a BMP Entity bean.
Plus, you are not even taking the SCJD exam currently, this is your only post you have ever posted here in the SCJD forum.
[ April 01, 2002: Message edited by: Mark Spritzler ]
[ April 01, 2002: Message edited by: Mark Spritzler ]
Bal Sharma
Ranch Hand

Joined: Sep 19, 2001
Posts: 273
I agree with Mark!
-Bal
sanz nsgha
Ranch Hand

Joined: Jan 18, 2002
Posts: 42
Java developers or a bunch of policemen? huh
Bal Sharma
Ranch Hand

Joined: Sep 19, 2001
Posts: 273
Originally posted by sanjay amatya:
Java developers or a bunch of policemen? huh

I wish you had understood the sprit of Developer forum. We share knowdlege on how to solve the SCJD assignment. Alas, If you had downloaded assignment, I am pretty sure you would not had asked JDBC question here. There is separate JDBC forum in JAVARANCH too.
Anyway, thanks for your kindness labeling a bunch of policemen for helping hands.
-Bal
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

Could a Sheriff or Bartender either lock this thread or delete it. It doesn't belong here.
Thanks
Mark
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDBC - BLOB question for Java gurus