Java Utililty Methods SQL Clob

List of utility methods to do SQL Clob

  1. HOME
  2. Java
  3. S
  4. SQL Clob

Description

The list of methods to do SQL Clob are organized into topic(s).

Method

String ConvertClobToString(StringBuffer sb, Clob clob)
Convert Clob To String
Reader reader = clob.getCharacterStream();
char[] buffer = new char[(int) clob.length()];
while (reader.read(buffer) != -1) {
 sb.append(buffer);
return sb.toString();
String convertClob2String(Clob clob)
Convert a Clob into String.
if (clob != null) {
 BufferedReader in = new BufferedReader(clob.getCharacterStream());
 String line = in.readLine();
 StringBuffer result = new StringBuffer();
 while (line != null) {
 result.append(line);
 line = in.readLine();
 return result.toString();
return null;
Object convert(Object o, Class targetType)
convert
if (o == null) {
 return null;
Class<?> currentType = o.getClass();
if (targetType.isAssignableFrom(currentType)) {
 return o;
if (targetType == String.class) {
...
String convertToString(Object obj)
convert To String
String value = "";
try {
 if (obj instanceof Clob) {
 value = ((Clob) obj).getSubString(1, (int) ((Clob) obj).length());
 } else {
 value = String.valueOf(obj);
 return value;
...
String getClobToString(Clob clob)
get Clob To String
if (clob != null) {
 try {
 return clob.getSubString((long) 1, (int) clob.length());
 } catch (SQLException e) {
 e.printStackTrace();
return null;
...
String getRSClob(Object obj, String def)
get RS Clob
if (obj == null)
 return def;
if (obj instanceof java.sql.Clob)
 return ((java.sql.Clob) obj).getSubString((long) 1, (int) ((java.sql.Clob) obj).length());
System.out.println("end of getRSClob, wrong object: " + obj.getClass().getName());
return def;
String getFormattedClobColumn(final InputStream is)
get Formatted Clob Column
final byte b[] = new byte[BUFFER_SIZE];
final BufferedInputStream bi = new BufferedInputStream(is);
final StringBuffer sb = new StringBuffer();
try {
 while ((bi.read(b)) != -1) {
 sb.append(new String(b));
} catch (final Exception e) {
...
String getString(Clob c)
get String
StringBuffer s = new StringBuffer();
if (c != null) {
 try {
 BufferedReader bufferRead = new BufferedReader(c.getCharacterStream());
 try {
 String str;
 while ((str = bufferRead.readLine()) != null) {
 s.append(str);
...
String getStringFromClob(Clob clob)
get String From Clob
String returnValue = null;
Reader reader = null;
try {
 if (clob != null && clob.length() != 0) {
 reader = clob.getCharacterStream();
 int clobSize = (int) clob.length();
 char[] buffer = new char[clobSize];
 reader.read(buffer);
...
boolean isNClob(final Class type)
is N Clob
return java.sql.NClob.class.isAssignableFrom(type);


AltStyle によって変換されたページ (->オリジナル) /