Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Storing large image files

 
sri chitra
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic