fR0DDY
fR0DDY

Reputation: 805

String to Clob in Java?

I have a string in java, but the datatype in database is Clob. How do i get a Clob from String?

Upvotes: 5

Views: 33665

Answers (3)

Anshul Karasi
Anshul Karasi

Reputation: 1

To Convert any String(small strings or big JSON converted to strings) in to CLOB we need to initialize CLOB first:

CLOB clob = (CLOB) con.createClob();
clob.setString(position, "Any String Here");

Where con is Connection

Upvotes: 0

Stan Sokolov
Stan Sokolov

Reputation: 2260

new javax.sql.rowset.serial.SerialClob(source.toCharArray())

Upvotes: 3

Vijay Mathew
Vijay Mathew

Reputation: 27164

clob.setString(position, string) writes a String to a Clob object.

Upvotes: 8

Related Questions