0
以下程序總是給異常CLOB到字符串轉換+的java 1.8
「java.sql.SQLRecoverableException:關閉連接」在此行中的「最後閱讀器讀取器= clb.getCharacterStream();」
import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
import java.sql.Clob;
import java.sql.SQLException;
public class ClobStringConversion {
public static String clobStringConversion(Clob clb) throws IOException, SQLException
{
if (clb == null)
return "";
StringBuffer sb = new StringBuffer();
String strng;
try{
final Reader reader = clb.getCharacterStream();
final BufferedReader br = new BufferedReader(reader);
int b;
while(-1 != (b = br.read()))
{
sb.append((char)b);
}
br.close();
}
catch (SQLException e)
{
//log.error("SQL. Could not convert CLOB to string",e);
return e.toString();
}
catch (IOException e)
{
//log.error("IO. Could not convert CLOB to string",e);
return e.toString();
}
return sb.toString();
}
}
您應該提供更多詳細信息,例如您正在使用的數據庫,JDBC驅動程序,CLOB的預期長度,這是間歇性還是每次都發生。 – 11thdimension
當前使用Oracle數據庫和jdbc驅動程序。 CLOB長度非常大。 – Ravikanth
如果您希望獲得幫助,則需要提供更多代碼。此錯誤消息表明,到目前爲止,套接字連接已關閉;您無法從封閉流中讀取數據。我們在這裏無能爲力。 –