Clob对象与String对象之间相互转换

/**

       * 功能:将 Clob对象转换为String对象

       * @param clob - clob 对象

       * @author ssy

       */

    public String ClobToString(Clob clob) {

      if(clob== null){

             return "" ;

      }

        String reString = "";

        Reader is = null;

        try {

            is = clob.getCharacterStream();

        } catch (Exception e) {

            e.printStackTrace();

        }

        // 得到流

        BufferedReader br = new BufferedReader(is);

        String s = null;

        try {

            s = br.readLine();

        } catch (Exception e) {

            e.printStackTrace();

        }

        StringBuffer sb = new StringBuffer();

        while (s != null) {

            sb.append(s);

            try {

                s = br.readLine();

            } catch (Exception e) {

                e.printStackTrace();

            }

        }

        reString = sb.toString();

        return reString;

    }

//将String 类型转换为Clob类型

//                if( content != null && !"".equals(content)){

////                    java.sql.Clob c = new javax.sql.rowset.serial.SerialClob(content.toCharArray());

//                      java.sql.Clob c = Hibernate.createClob(content);

//                      

//                }

你可能感兴趣的:(clob,java)