• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in inserting large file in CLOB in Oracle

 
sandy comp
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • 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.

------------------
 
Kripal Singh
Ranch Hand
Posts: 254
  • 0
  • Mark post as helpful
  • send pies
  • 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();}
}
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic