• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.sql.SQLException: Invalid argument(s) in call @ When working with CLOB

 
Sravani cg
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,


I got below error when working CLOB. Initially i am inserted CLOB column with empty_clob() and then converting String Data in to CLOB and then update same in CLOB Column.

Previously with the same code its working fine. Not its not working as expected and throws below exception.


I am received above error on line clobWriter = clob.setCharacterStream(0L).

ERROR :

java.sql.SQLException: Invalid argument(s) in call
at oracle.jdbc.driver.T4CConnection.newWriter(T4CConnection.java:3497)
at oracle.sql.CLOB.setCharacterStream(CLOB.java:1168)

CODE :

------
------
pstmt = connection.prepareStatement("SELECT DATA_COLUMN FROM X_TABLE WHERE ID=? FOR UPDATE");
pstmt.setInt(1, sqTranId);
rs = pstmt.executeQuery();
if(rs.next()){
CLOB clob = (CLOB) rs.getClob(1);
populateCLOB(clob,saveQteRequest.getSrbSaveCopyBookASString());
}

----------------------
private void populateCLOB(oracle.sql.CLOB clob, String data) throws IOException, SQLException {
StringReader reader = null;
Writer clobWriter = null;
try {
reader = new StringReader(data);

clobWriter = clob.setCharacterStream(0L);

// Get optimal buffer size to read/write data
char[] buffer = new char[clob.getBufferSize()];
int read = 0;
int bufflen = buffer.length;

// Read from String and write to CLOB
while ((read = reader.read(buffer, 0, bufflen)) > 0) {
clobWriter.write(buffer, 0, read);
}
} catch (Exception e) {
ioe.printStackTrace();
}
}


Please help me...!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic