Convert String to Clob in Java

Reddy picture Reddy · Jul 11, 2012 · Viewed 79.1k times · Source

I have a situation where I need to make Clob object from String. The problem is I can't have ConnectionManager in that method.

I need to some utility like

 public Clob getClob(String data){

 }

Can any one tell me how can I make this.

I have oralce.sql.CLOB also. however it requires Connection to create object.

Answer

Nibin Jacob Panicker picture Nibin Jacob Panicker · Feb 27, 2018

Those who are still looking for an alternate answer, a Clob object could be created without the need for a connection object as shown below.

Clob myClob = new javax.sql.rowset.serial.SerialClob(stringData.toCharArray());