• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Problem in inserting large file in CLOB in Oracle

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi friends.
I have problem while inserting data into CLOB datatype of Oracle. I'm able to insert samll files into CLOB say having 4000 characters, but if this limit exceds I'm unable to insert file into CLOB. I tried both otions on java.sql.PreparedStatement
viz. setAsciiStream() and setBinaryStream().
Anyone have solution on this. Please let me know as early as possible.
Thanks in advance.

------------------
 
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
are you doing somthing like this . if not try it .
...
...
//your code
stmt = conn.createStatement();
rs1 = stmt.executeQuery("select * from mytable where mycolumn = "+myvar
+" for update");
if(rs1.next())
{
my_clob = ((OracleResultSet)rs1).getCLOB(yourcolumnindex);
insertClob(my_clob,myclobvalue);
}
stmt.execute("commit");
rs1.close();
stmt.close();
...
...
public void insertClob(oracle.sql.CLOB clob,String value) throws Exception
{
try
{
OutputStream outstream = clob.getAsciiOutputStream();
outstream.flush();
outstream.write(value.getBytes());
outstream.close();
}catch(Exception e){e.printStackTrace();}
}
 
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://otn.oracle.com/sample_code/tech/java/sqlj_jdbc/files/advanced/advanced.htm
There is source code to an example using LOB's. The writeCLOB(...) method uses a different approach to writing the CLOB.
Jamie
 
I like tacos! And this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic