• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem in inserting pdf file  RSS feed

Shyam Sunder
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my source code for inserting pdf file into oracle.
This code is working for only small size pdf (like 16 kb) if iam tring to insert a pdf file which is more than 2 mb.

Its giving the exception as given below.

import java.io.File;
import java.io.FileInputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;

public class PDFConnect

public static void main(String args[])
Connection conn = DriverManager.getConnection("jdbcracle:thin:@", "TESTPTS", "TESTPTS");
System.out.println("connection established");
PreparedStatement ps = conn.prepareStatement("insert into DEMOBLOB values(?)");
System.out.println("insert executed");
File photo= new File("D:/Thinkingjava.pdf");
System.out.println("image loaded ");
FileInputStream photostream= new FileInputStream(photo);
System.out.println("photo taken");


catch(Exception e)

connection established
insert executed
image loaded
photo taken
java.sql.SQLException: ORA-01460: unimplemented or unreasonable conversion requested

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:114)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:542)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1311)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:738)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:1313)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1232)
at oracle.jdbc.driver.OracleStatement.doExecuteWithBatch(OracleStatement.java:1353)
at oracle.jdbc.driver.OracleStatement.doExecute(OracleStatement.java:1760)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1807)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:332)
at PDFConnect.main(PDFConnect.java:24)
Scott Selikoff
Posts: 4087
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should look up tutorials on blobs, inserting them can be tricky.

Last I recall in some systems it requires two passes for an insert. The first insert without the blob creates the db record and makes available a pointer to the blob. Then an update is performed using that pointer. That would seem to support the error, it doesn't want to insert a blob directly, it wants the db to create one and then you to set it.
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!