方法一:
public final static String clob2String(CLOB clob)
{
if (clob ==null )
{
return ;
}
StringBuffer sb = new StringBuffer(65535);//64K
Reader clobStream = null;
try
{
clobStream = clob.getCharacterStream();
char[] b = new char[60000];//每次获取60K
int i = 0;
while((i = clobStream.read(b)) != -1)
{
sb.append(b,0,i);
}
}
catch(Exception ex)
{
sb = null;
}
finally
{
try
{
if (clobStream != null)
clobStream.close();
}
catch (Exception e)
{
}
}
if (sb == null)
return ;
else
return sb.toString();
}
public static String clob2string(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);
}
}
catch(Exception ex){
ex.printStackTrace();
}
finally{
try{
if(instream != null) instream.close();
}
catch(Exception dx){
instream = null;
}
return sb.toString();
}
}
方法三:
public String getText(String s)
throws SQLException
{
String s1 = "";
char ac[] = new char[200];
CLOB clob = (CLOB)result.getObject(s);
if(clob == null)
return null;
Reader reader = clob.getCharacterStream();
int i;
try
{
while((i = reader.read(ac, 0, 200)) != -1)