Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

This paper briefly introduces two methods of reading Oracle large field data (CLOB) by Java.

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces two methods for Java to read Oracle large field data (CLOB). It is introduced in great detail through the sample code, which has a certain reference value for everyone's study or work. Friends who need it can refer to it.

A field in the Oracle database is of type CLOB and is parsed using java.

1. Use java to parse clob type content public String clobToString (Clob c) {StringBuffer sb = new StringBuffer (1024); Reader instream = null; try {instream = c.getCharacterStream (); char [] buffer = new char [(int) c.length ()]; int length = 0; while (length = instream.read (buffer)! =-1) {sb.append (buffer, 0, length) } catch (Exception ex) {ex.printStackTrace (); return null;} finally {try {if (instream! = null) instream.close ();} catch (Exception dx) {instream = null;}} return sb.toString () } if (pageObject.getResultList ()! = null & & pageObject.getResultList (). Size () > 0) {for (int iPageObject. GetResultList (). Size (); I < Mapmaps (Map) pageObject.getResultList (). Get (I); maps.put ("DISPATCHINGRULESNAME", this.clobToString ((Clob) maps.get ("DISPATCHINGRULESNAME") / / convert the Clob type to a string and call the clobToString ((Clob) method}} 2. Use the oracle function to_char (field) select to_char (t.billName) as billName from T_CC_SHARE_DISPATCH_RULE t

The above is the whole content of this article. I hope it will be helpful to your study.

The original text is from: https://www.linuxprobe.com/java-oracle-linux.html

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report