File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Problem regarding Image save/retrieve Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Problem regarding Image save/retrieve " Watch "Problem regarding Image save/retrieve " New topic
Author

Problem regarding Image save/retrieve

kshitij raval
Greenhorn

Joined: Oct 20, 2001
Posts: 15
java.sql.SQLException: ORA-01461: can bind a LONG value only for insert into a LONG column
I encountered this exception only when I try to save a big image. The jpg image was only as big as 5436 bytes.
The reason for this exception is explained at http://www.wamoz.com/JDBC_and_Oracle_LOB.asp, that
LONG data types (LONGVARBINARY, LONGVARCHAR etc) are the original kind of blob. Because the LONG data is fetched with each row, this makes each fetched row potentially very large. It uses up the fetch buffer very quickly and makes the database server much less efficient because far fewer rows will fit in memory.
The site has also given the solution in the form of downloads, but there is dependency on two of its packages:
(1) com.Trysoft.bpe and (2) com.wamoz.db. And discussed that the solution to this is saving a big image in small chunks.
I am interested in solving this problem using pure Java, i.e., either JDK1.2 or JDK1.3 classes ONLY. Can anyone help me out?
kshitij raval
Greenhorn

Joined: Oct 20, 2001
Posts: 15
I have not yet found the solution to saving big images in Oracle using Java can anyone help ???
Suresh Kanagalingam
Ranch Hand

Joined: Aug 17, 2001
Posts: 82
Hi Kshitij,
I encountered similar problem when I tried to read large images from Oracle Blob. During testing I found out that I cound not read any image greater than 32K. Here is how I got around. I read the blob until I finish reading in 32K chunks - storing the data in temp place holder. The code below:
++++++++++++++++++++++++++++++++++++++++++++++++++++
try
{
int byteCount = 0;
int newLength = 0;
int readLength = 0;
while ( newLength < blobLen)
{
if ((newLength+32500) <= blobLen)
{
data = blob.getBytes (newLength+1, 32500);
newLength = newLength + 32500;
readLength = 32500;
}
else
{
readLength = (int) (blobLen - newLength);
data = blob.getBytes (newLength+1, readLength);
newLength = newLength + readLength;
}

for (byteCount = 0; byteCount < readLength; byteCount++)
{
try
{
TIFFFile.write (data[byteCount]);
}
catch (Exception e)
{
System.err.println ("Error writing data for TIFF @ address " + newLength);
return;
}
}
}
}
catch (Exception e)
{
System.out.println ("Exception: Unable to write output file: "+e.getMessage());
return;
}
+++++++++++++++++++++++++++++++++++++++++++++

This may help.
Good luck.
------------------
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem regarding Image save/retrieve