我有在找出什麼是這裏的問題大傷腦筋從Oracle CLOB ..閱讀使用Hibernate
我從會話工廠一個會話,然後得到CLOB出持續性的對象。當涉及到clob.getCharcterStream()或getAsciiStream()時,它會拋出異常 - 關閉連接。
有人可以幫助我這個。
代碼:
Session session = Dao.getSession(connId);
Package pack = (Package) session.load(Package.class, packId);
Hibernate.initialize(pack);
Clob reportClob = pack.getExpReportFile();
String result = null;
InputStream stream = null;
try
{
System.out.println(session.isConnected() + " " + session.isOpen());
stream = reportClob.getAsciiStream();
result = IOUtils.toString(stream);
}
catch (SQLException e)
{
e.printStackTrace();
}
return result;
例外:
true true
java.sql.SQLException: Closed Connection
at oracle.sql.CLOB.getDBAccess(CLOB.java:1389)
at oracle.sql.CLOB.getAsciiStream(CLOB.java:330)
at org.hibernate.lob.SerializableClob.getAsciiStream(SerializableClob.java:68)
at com.server.WebServiceImpl.fetchPackageReport(WebServiceImpl.java:2070)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:562)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:188)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:224)
at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
關閉自動提交不起作用AYUSH ..和一個開放的交易,我插session.beginTransaction()緊跟在Hibernate.initialize()語句後面,也沒有解決.. – JSixface 2011-02-07 18:04:15
是哪個oracle數據庫呢? oracle 9? – ayush 2011-02-07 18:20:39