wood burning stoves 2.0*
The moose likes JDBC and the fly likes Storing large String in CLOB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Storing large String in CLOB" Watch "Storing large String in CLOB" New topic
Author

Storing large String in CLOB

Syed Naeem
Greenhorn

Joined: Jun 22, 2001
Posts: 2
I'm trying to store large string (> 4000 Characters)in Clob data column of Oracle database. I tried,,,,
Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
ResultSet rs = statement.executeQuery("SELECT clobData from myTable");
rs.next();
oracle.sql.CLOB xClob = rs.getClob(1); //works fine
OutputStream os = xClob.getAsciiOutputStream();
//I've to store String m_procedureText;
os.write(m_procedureText.getBytes());
os.flush();
os.close();
The compiler is throwing the following exception:
ROW containing the LOB value is not locked
>>Any suggestion regarding how to lock the ROW before updating its CLOB column.

prabhat kumar
Ranch Hand

Joined: Apr 11, 2001
Posts: 114
the lines u need to add before creating statement ..
1. set the sutocommit mode to false.
connection.setAutocommit(false);
and
2. if u r going to update the column then use select for update query to lock the row.
like this
select col from table for update.
hope it will help
if any errors please post them
Originally posted by Syed Naeem:
I'm trying to store large string (> 4000 Characters)in Clob data column of Oracle database. I tried,,,,

Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
ResultSet rs = statement.executeQuery("SELECT clobData from myTable");
rs.next();
oracle.sql.CLOB xClob = rs.getClob(1); //works fine
OutputStream os = xClob.getAsciiOutputStream();
//I've to store String m_procedureText;
os.write(m_procedureText.getBytes());
os.flush();
os.close();
The compiler is throwing the following exception:
ROW containing the LOB value is not locked
>>Any suggestion regarding how to lock the ROW before updating its CLOB column.

Syed Naeem
Greenhorn

Joined: Jun 22, 2001
Posts: 2
I also tried it with UPDATE statement, but doesnt help. The, "SELECT columnName from tableName for UPDATE" statement works in sqlplus, but not through JDBC3.0.
the lines u need to add before creating statement ..
1. set the sutocommit mode to false.
connection.setAutocommit(false);
and
2. if u r going to update the column then use select for update query to lock the row.
like this
select col from table for update.
hope it will help
if any errors please post them

quote:
--------------------------------------------------------------------------------
Originally posted by Syed Naeem:
I'm trying to store large string (> 4000 Characters)in Clob data column of Oracle database. I tried,,,,
Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
ResultSet rs = statement.executeQuery("SELECT clobData from myTable");
rs.next();
oracle.sql.CLOB xClob = rs.getClob(1); //works fine
OutputStream os = xClob.getAsciiOutputStream();
//I've to store String m_procedureText;
os.write(m_procedureText.getBytes());
os.flush();
os.close();
The compiler is throwing the following exception:
ROW containing the LOB value is not locked
>>Any suggestion regarding how to lock the ROW before updating its CLOB column

[This message has been edited by Syed Naeem (edited June 24, 2001).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Storing large String in CLOB