Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-21-2008, 02:30 PM
Member
 
Join Date: Jul 2008
Posts: 4
ravee is on a distinguished road
image retrieval from sql server using java
Hi,
our clients have a sql server database in which one of the table column of image data type holds a image. The problem is, the column holds image along with some other data which they are doing by using some appendchunk method from VB. they are able to retrieve the image from the column with the help of a method called GetChunk in VB, now i have to do the same thing from java but I am not able to retrieve the image. I have tried resultset.getBytes() & getBinaryStream() by (they are giving the image size in another column) using the imgsize column, I have tried retrieving only certain no of bytes, but not able to see the image. If any body knows about this issue plz reply.......
Following is the method they are using to retrieve the image using VB code:
GetChunk(0, recset("imgsize") * 2)
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-21-2008, 03:23 PM
Member
 
Join Date: Jul 2008
Posts: 31
skaspersen is on a distinguished road
You need to access the column as a blob.

Code:
Blob blob = resultSet.getBlob("imgColumn"); BufferedInputStream in = new BufferedInputStream(blob.getBinaryStream());
Then use in as if it were a file

HTH
Stephen

Last edited by skaspersen : 07-21-2008 at 03:27 PM.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-22-2008, 07:33 AM
Member
 
Join Date: Jul 2008
Posts: 4
ravee is on a distinguished road
I have tried like this, but not working...

Quote:
Originally Posted by skaspersen View Post
You need to access the column as a blob.

Code:
Blob blob = resultSet.getBlob("imgColumn"); BufferedInputStream in = new BufferedInputStream(blob.getBinaryStream());
Then use in as if it were a file

HTH
Stephen
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 07-30-2008, 01:44 AM
fishtoprecords's Avatar
Senior Member
 
Join Date: Jun 2008
Posts: 459
fishtoprecords is on a distinguished road
What, specifically, is not working?

Are you getting the bytes and can't display them? or can't get the bytes?

As a test, retreive the bytes and write them out to a file and try to open the file with an image viewer program
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 08-01-2008, 08:53 AM
Member
 
Join Date: Jul 2008
Posts: 4
ravee is on a distinguished road
I am able to get the bytes, but its not able to show the image...
they are inserting the image by using some AppendChunk method in VB and as a proof they are able to get the image properly by using a method called GetChunk. From net I came to know that GetChunk returns bytes only, but when I try to get the image from java its not getting retrieved properly. Can u plz tell if there is any specific procedure to retrieve the image if it is inserted by using AppendChunk. some method like that of GetChunk in VB...
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 08-01-2008, 03:53 PM
Member
 
Join Date: Jul 2008
Posts: 31
skaspersen is on a distinguished road
What format is the image? Is it BMP?
Java does not display a windows bitmap file, you have to write your own decoder.

Have you written the data to a file and tried to open it from an external image viewer eg "Windows Picture and Fax Viewer" as fishtoprecords suggested?

Is the column type on the server varchar? If so you may have this problem The getBytes function incorrectly converts the raw bytes in the varchar data type column to the lower byte of the Unicode representation in the SQL Server 2000 Driver for JDBC

Last edited by skaspersen : 08-01-2008 at 03:57 PM.
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 08-22-2008, 02:52 PM
Member
 
Join Date: Jul 2008
Posts: 4
ravee is on a distinguished road
1. I tried viewing the file using Windows Picture and Fax Viewer, no result...
2. No the column type is image.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
image download from server willemjav Java Applets 2 04-04-2008 12:13 AM
Regarding retrieval of sheet names from a excel workbook yuvaraj23 New To Java 0 03-11-2008 04:20 PM
Converting multiple banded image into single banded image... Image enhancement archanajathan Advanced Java 0 01-08-2008 07:29 PM
Server socket - send image to client Hinty Networking 0 11-30-2007 10:15 PM
Lucene Image REtrieval 0.5.4 JavaBean Java Announcements 0 07-11-2007 05:54 PM


All times are GMT +3. The time now is 01:28 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org