How to insert > 4000 char to clob in oracle

I am trying to insert a row of a string of more than 4000 characters in
clob datatype field using java program and it gives the following error
ORA-01704: string literal too long. I knew the solution is to use storedprocedure to insert the data. With this way, i need to make a lot of changes in the program. So, would like to check can i declare the field size for clob something like DB2?
LVL 1
chinswAsked:
Who is Participating?
 
CEHJConnect With a Mentor Commented:
Use PreparedStatement.setCharacterStream
0
 
tigin44Commented:
can you provide java part of your code doing the insert..
0
 
chinswAuthor Commented:
I just do the normal insert as below:

 db.addBatchSql( "Insert into MM002 (P9_MM002_EREC_KEY, F9_MM002_CRE_TMS, FX_MM002_RCV_MSG_VER, FX_MM002_RCV_MSG_ID,FX_MM002_MERCHEQ_XML) " +
 "values ("+recKey+", "+recvTimeStamp+", '"+xmlvalidator.getVersion()+"', '"+xmlvalidator.getMsgId()+"', '"+xmlMsg+"')" );

FX_MM002_MERCHEQ_XML is a clob field in oracle and xmlMsg is String data type in Java
                   
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
chinswAuthor Commented:
I can't use the oracle.jdbc because i need to make my application generic to support different database platform (oracle/db2). Any way to solve this problem?
0
 
sompol_kiatkamolchaiCommented:
Please make sure that you data type is CLOB because 4000 characters is a limit size of VARCHAR2
0
 
Kevin CrossChief Technology OfficerCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.