File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Storing large image files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Storing large image files" Watch "Storing large image files" New topic

Storing large image files

sri chitra

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.setBinaryStream(2, new FileInputStream(file), (int) file.length());
Frank Wang

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.
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.
Sample for Oracle Tech net:
Sample from Javasoft:
I agree. Here's the link:
subject: Storing large image files
It's not a secret anymore!