• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem in inserting pdf file

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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[])
{
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@10.81.7.169:1521:PTS", "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");
ps.setBinaryStream(1,photostream,(int)photo.length());
ps.executeUpdate();
photostream.close();

}

catch(Exception e)
{
e.printStackTrace();
}
}
}


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)
 
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ruth Stout was famous for gardening naked. Just like this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic