String to Clob in Java?

I have a string in java, but the data type in the database is Clob. How to get Clob from String?

+3
source share
3 answers

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

+5
source

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

+3
source

To convert any string (small strings or large JSON converted to strings) to CLOB, we need to initialize the CLOB first:

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

Where conis the connection

0
source

Source: https://habr.com/ru/post/1785337/


All Articles