This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes Displaying an Oracle BLOB image. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Displaying an Oracle BLOB image." Watch "Displaying an Oracle BLOB image." New topic
Author

Displaying an Oracle BLOB image.

achana chan
Ranch Hand

Joined: Jul 29, 2002
Posts: 277
Hi.
I believe I have successfully created a "serialized" record e.g. empRecord.class
It holds the data retrieved from an Oracle table.
However I have this problem of trying to get at the BLOB field in empRecord.class from the Applet.
Getting at "serialized" text or numeric fields seem to be quite easy in comparison !
Also I hope I am using the right terminology when I say "serialized" e.g.

I think I know how to connect to the database , create input/output streams and get at an image, but from the Applet, how exactly do I get at this Oracle BLOB in the serialized record ?
Is it possible to create a "window" (java.awt.window) and display the image in it ?

How does one get the "serialized" image into the window ?
Sometimes I despair with JAVA, after nearly 5 months of coding, I am still floundering. Also this proliferation of terminology and packages and tools is very confusing and unhelpful.
It would be nice to know how many of you out there remembers all the classes and methods and whatnot.
[ October 31, 2002: Message edited by: achana chan ]

humanum errare est.
Michael Zalewski
Ranch Hand

Joined: Apr 23, 2002
Posts: 168
You don't give very specific information. But your problem might be trying to serialize a BLOB. Serialize the byte[] from the BLOB instead. A Blob object is only useful while you are connected to the database, and the database connection probably doesn't travel with whatever the heck it is you are serializing to.
Replace

with
achana chan
Ranch Hand

Joined: Jul 29, 2002
Posts: 277
Hi Michael.
Thanks for the tip.
If I change BLOB to byte[], I have several errors:
On the server side, neither the text data nor the blob is retrieved from the database .
On the client side, the JAVA console throws these distressing errors :
BaseTunnelClient : content-length is 91
BaseTunnelClient : connecting... JSESSIONID=B0959584F5E504ED7B02454C9A277907
java.io.IOException: Server returned HTTP response code: 500 for URL: http://192.168.1.3/saysit/RemotedemoServer
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sun.plugin.net.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getHeaderFields(Unknown Source)
at sun.plugin.net.protocol.http.HttpURLConnection.checkCookieHeader(Unknown Source)
at sun.plugin.net.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at com.developer.Tunnel.client.BaseTunnelClient._invokeMethod(BaseTunnelClient.java:194)
at com.developer.Tunnel.RemotedemoClient.query(RemotedemoClient.java:100)
at com.developer.Tunnel.demoApplet.actionPerformed(demoApplet.java:194)
at java.awt.Button.processActionEvent(Unknown Source)
at java.awt.Button.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
com.developer.Tunnel.client.BaseTunnelClient$TunnelException: Server returned HTTP response code: 500 for URL: http://192.168.1.3/saysit/RemotedemoServer
at com.developer.Tunnel.client.BaseTunnelClient._invokeMethod(BaseTunnelClient.java:217)
at com.developer.Tunnel.RemotedemoClient.query(RemotedemoClient.java:100)
at com.developer.Tunnel.demoApplet.actionPerformed(demoApplet.java:194)
at java.awt.Button.processActionEvent(Unknown Source)
at java.awt.Button.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
achana chan
Ranch Hand

Joined: Jul 29, 2002
Posts: 277
Dear Michael,
This is how I set empRecord.class ie serialize it, I snipped the code because it is a long tedious piece of code :
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

You could try read this post: http://www.coderanch.com/t/297456/JDBC/java/Retreiving-image-JDBC
Rene


Regards, Rene Larsen
Dropbox Invite
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Displaying an Oracle BLOB image.
 
Similar Threads
How to store & retrieve a video file from database?
Using BLOB in java
How to add image in a pop up
How to retreive a blob....
uploading image into oracle database through servlet