string To Clob - Java java.sql

Java examples for java.sql:Clob

Description

string To Clob

Demo Code


//package com.java2s;

import java.sql.Clob;

public class Main {
    public static void main(String[] argv) throws Exception {
        String str = "java2s.com";
        System.out.println(stringToClob(str));
    }//from   w  ww.  jav  a 2 s  . c om

    public static Clob stringToClob(String str) {
        if (null == str) {
            return null;
        } else {
            try {
                java.sql.Clob c = new javax.sql.rowset.serial.SerialClob(
                        str.toCharArray());
                return c;
            } catch (Exception e) {
                return null;
            }
        }
    }
}

Related Tutorials