aspose file tools*
The moose likes JDBC and the fly likes Problem in inserting large file in CLOB in Oracle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Problem in inserting large file in CLOB in Oracle" Watch "Problem in inserting large file in CLOB in Oracle" New topic
Author

Problem in inserting large file in CLOB in Oracle

sandy comp
Greenhorn

Joined: Aug 11, 2001
Posts: 10
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.

------------------

Design and programming are human activities; forget that and all is lost.
Kripal Singh
Ranch Hand

Joined: Jul 26, 2001
Posts: 254
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();}
}

# Help an unprivileged kid.<br /> Whatever u do will make a difference...<br /> ...to a child's life & ur own #<br /><a href="http://www.cry.org/" target="_blank" rel="nofollow">www.cry.org/</a>
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

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
 
 
subject: Problem in inserting large file in CLOB in Oracle