Search code examples
javasqlstringclob

Convert String to Clob in Java


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.


Solution

  • Try this :

    OracleConnection conn;  // initialize this first
    
    CLOB clob = conn.createClob();
    
    public Clob getClob(String data){
    
        return clob.setString(position, data);
    }