Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Storing large String in CLOB

 
Syed Naeem
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic