At which line of your code does the exception occur?
This error indicates an attempt to convert CLOB to VARCHAR failed because the text in the CLOB was too long (this explains it fails only sometimes -- when the text is too long). Aren't you trying to insert the created CLOB into a VARCHAR column?
posted 6 years ago
I am trying to insert clob type data into clob column not varchar type column. This was running fine but suddenly this message started
Does the error occur at the INSERT statement? Can you post the code containing the insert statement, and ideally the table description (output from DESCRIBE TABLE) so that we can see the full path the CLOB takes from its creation?
It is possible to create a CLOB in Oracle directly in the table, using empty_clob() function, and populate it afterwards. That would prevent any conversions, but make your code Oracle specific.
posted 6 years ago
SQL*Plus: Release 184.108.40.206.0 Production on Fri Sep 20 20:25:17 2013
Copyright (c) 1982, 2010, Oracle. All rights reserved.
SQL> desc cvs
Name Null? Type
----------------------------------------- -------- ----------------------------
CV_ID NOT NULL NUMBER(14)
You need to set the parameters in the order corresponding to the columns listed in the INSERT INTO statement. Last three columns in your statement are hobbies, achievements and references. The table description you've posted shows these columns are of the VARCHAR2 type. The database then tries to convert CLOB to VARCHAR2 and this fails when the maximum VARCHAR2 length is exceeded.
In my opinion, the real bug in your code is that you're inserting wrong values into the respective columns. The column order and the parameter order don't match.
Edit: you've figured it yourself before I've finished my reply. But the next paragraph probably still applies.
Furthermore, you're setting numeric values (eg. user_id or cat_id) using setString(). This causes implicit conversion from varchar to numeric value in the database, and might prove to be problematic if your database locale changes. Always set the parameters in the most precise type possible - in this case, probably a setLong() would be appropriate. See avoiding implicit conversions for further information.