• 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

Insert file to Oracle's BLOB

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I using the following codes to insert the file in RAW LONG Column and it works O.K. But when I change the column type to BLOB, it throws the exception.

File file = new File (args[0]);
InputStream inStream = new FileInputStream (file);
PreparedStatement psmt = conn.prepareStatement
("INSERT INTO vp_doc (name,doc) VALUES (?, ?)");
psmt.setString (1, args[0]);
psmt.setBinaryStream (2, inStream,(int)file.length () );
psmt.execute ();

Below are the exception :

Exception in thread "main" java.sql.SQLException: No more data to read from sock
et
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:1160)
at oracle.jdbc.ttc7.MAREngine.unmarshalUB1(MAREngine.java:963)
at oracle.jdbc.ttc7.MAREngine.unmarshalSB1(MAREngine.java:893)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:369)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:109
3)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.ja
va:2047)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.jav
a:1940)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStateme
nt.java:2709)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePrepar
edStatement.java:589)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStat
ement.java:656)
at UploadFile.main(UploadFile.java:28)

Who can point out my mistake ?
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You may want to have a look at the LOB Datatype Sample on OTN
Sujatha.
Oracle Technology NetworkOracle Technology Network
 
kwwong wong
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The sample in OTN is an client application and using SELECT FOR UPDATE. Can I using this sample in Web Application ? I remember that SELECT FOR UPDATE cannot use in WEB application, is it true ?
Thanks
 
Life just hasn't been the same since the volcano erupted and now the air is full of tiny ads.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic