aspose file tools*
The moose likes JDBC and the fly likes Storing large image files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Storing large image files" Watch "Storing large image files" New topic
Author

Storing large image files

sri chitra
Greenhorn

Joined: Nov 16, 2000
Posts: 22
I am getting problem when I try to store large image files
into blob column. I am getting ORA-01461: can bind a LONG value only for insert into a LONG column when I tried to insert
large image files. It works fine for small image files. The code
is as follows;
PreparedStatement stmnt = conn.prepareStatement(
"insert into tempfile (name,file_blob) values (?,?)");

stmnt.setString(1,"temp");
stmnt.setBinaryStream(2, new FileInputStream(file), (int) file.length());
stmnt.execute();
stmnt.close();
Frank Wang
Greenhorn

Joined: Aug 18, 2000
Posts: 25
Hi, Sri, I am not quite sure how big your image files are.
My experience is to save the image names in Oracle and the actual image files separately. Although you can save image files in Oracle DB, you can have problem when an image file is too large.
Frank W.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I am able to store large images based on
the Advanced JDBC samples from Oracle Technology Network.
These samples use oracle.sql and oracle.jdbc.driver packages.
I coudnt get the sample from the javasoft site to work with
large images. It works with very small images. I dont know why since no exceptions are getting thrown.
URLs:
Sample for Oracle Tech net: http://technet.oracle.com/sample_code/tech/java/sqlj_jdbc/sample_code_index.htm
Sample from Javasoft: http://developer.java.sun.com/developer/onlineTraining/Database/JDBC20Intro/exercises/BLOBGet/index.html)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Storing large image files
 
Similar Threads
Problem regarding Image save/retrieve
1-to-M mapping confusion
File Upload Question
Hibernate exception - could not insert
ORA-01460: unimplemented or unreasonable conversion requested