[求助]SQLException: ResultSet is closed
public ResultSet getBookList(){ PreparedStatement ptmt = null; Connection con = getDBConnection();//我寫的連線方法 try{ ptmt = con.prepareStatement("select * from bookInfo"); System.out.println ("可以執行到這裡"); return ptmt.executeQuery(); }catch(SQLException e){ e.printStackTrace(); return null; }finally{ try{ ptmt.close(); con.close(); }catch(SQLException e){ e.printStackTrace(); } } } <p class="indent"> |
不用finally就沒問題,能返回記錄集
用了就出現SQLException: ResultSet is closed
應該是先執行 return ptmt.executeQuery();
返回一個記錄集,再執行finally啊
為什麼我加上finally他就說我記錄集以關閉
那位大大隻指點指點啊,我先謝謝了
相關文章
- Install Error : ERROR:SQLException null Resultset [ID 875002.1]ErrorSQLExceptionNull
- 求助:c3p0不定期出現SQLException: An attempt ...異常SQLException
- 求助:移動端登入測試,報錯 RemoteDisconnected Remote end closed connection without response。REM
- 解決okhttp報java.lang.IllegalStateException: closed,java.lang.IllegalStateException: closedHTTPJavaException
- DataIntegrityViolationException SQLExceptionAIExceptionSQL
- 3.2.2 Opening a Closed DatabaseDatabase
- java.lang.IllegalStateException: closedJavaException
- 結果集 (ResultSet)全面解析
- ResultSet.next() 慢定位
- Oracle JDBC ResultSet引數測試OracleJDBC
- ResultSet的方法和結構分析
- JDBCTM 指南:入門5 - ResultSet (轉)JDBC
- Spider closed (finished) 沒完成IDE
- java.sql.SQLException: Scope not recognizedJavaSQLExceptionZed
- Hibernate中的ResultSet的處理
- javax.servlet.ServletException: 用盡的 ResultsetJavaServletException
- 最有效的ResultSet轉換為JSON?JSON
- 求助webserviceWeb
- 求助,(javabean)JavaBean
- 求助高手
- WebService求助Web
- 執行Sybase儲存過程並返回ResultSet儲存過程
- java.sql.SQLException: Incorrect string valueJavaSQLException
- java.sql.SQLException: 數字溢位JavaSQLException
- [求助]求助java 高手幫忙做畢設,急!Java
- python求助Python
- go vendor 求助Go
- jdon框架求助框架
- java新手求助。。。。。。。。。。。Java
- 畢設求助
- python程式碼錯誤RuntimeError: Session is closedPythonErrorSession
- [Clickhouse] Clickhouse 報SQLException : Read timed outSQLException
- java.sql.SQLException: Fail to convert to internal representationJavaSQLExceptionAI
- Repca: Error -Sqlexception On Getting Sid And Systemname InformationPCAErrorSQLExceptionORM
- [求助] 使用 Selenium 進行拖拽操作不成功,求助
- org.hibernate.exception.SQLGrammarException: could not extract ResultSet解決方案ExceptionSQL
- Oracle 12c RMAN Cross-Platform Transport of a Closed PDBOracleROSPlatform
- 介面測試求助