Convert String To Clob In Java
Answer :
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());
Throws warning: Clob not initialized.
You need an OracleConnection to create a Clob, using the Oracle Database.
OracleConnection conn; // initialize this first
Clob myClob = conn.createClob();
private OracleConnection conn = null;
public void setConnection( OracleConnection conn )
{
this.conn = conn;
}
void setClob( String cookie ) throws SQLException
{
Clob myClob = conn.createClob();
myClob.setString( 1, cookie);
}
Try this :
OracleConnection conn; // initialize this first
CLOB clob = conn.createClob();
public Clob getClob(String data){
return clob.setString(position, data);
}
Comments
Post a Comment