Convert a string to CLOB

We have a large string that needs to be saved in the database. The database tables are created with the CLOB object.

We are using a JDBC adapter. The adapter service fails with a Service exception, when the string is directly mapped. (Error Message : The input data for the FIELD “longText” is not “java.sql.Clob”

What type of typecasting must be done to achieve a clob object from a string.


You have to create a CLOB object and put your string data into it. Simple Casting will not work in this case to my knowledge.
Depending on what DB you are using SQL, Oracel, DB2 or others creating a CLOB object will be DB dependent and cahlanging. Depending on DB it can be convoluted. Forexample DB2 provides a rather simple Factory to craete your CLOB objects and you can fill them with your data later. Oracle has similar but requires active DB connection and Java code to imlpement it. In any case you likely to need to create Java service to create java.sql.Clob object from your string before you map it in JDBC adapter service.