开发者

String to Clob in Java?

开发者 https://www.devze.com 2023-02-04 08:59 出处:网络
I have a string in java, but the datatype in database is Clob. How do i get a Clob fro开发者_JS百科m String?clob.setString(position, string) writes a String to a Clob object.new javax.sql.rowset.seria

I have a string in java, but the datatype in database is Clob. How do i get a Clob fro开发者_JS百科m String?


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


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消