2017-02-09 26 views
0

我正在使用spring jdbc模板從oracle數據庫中檢索400條記錄。 之後,我使用行映射器將行轉換爲對象。對象中的某些值沒有任何值。當我在pl/sql編輯器中測試相同的sql時,我能夠看到行的所有行和所有列。當我調試應用程序時,我得到錯誤。如果我爲相同的查詢獲取更少數量的記錄(7),它工作正常.Row映射器正在設置對象的所有值。你能幫我解決這個問題嗎?Spring Jdbc模板行映射器未設置對象中的所有值

java.sql.SQLException: statement handle not executed 

2017-02-09 15:45:39 INFO XmlBeanDefinitionReader:317 - Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml] 
2017-02-09 15:45:39 INFO SQLErrorCodesFactory:126 - SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase, Hana] 
2017-02-09 15:45:39 WARN SQLErrorCodesFactory:227 - Error while extracting database product name - falling back to empty error codes 
org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is java.sql.SQLException: Connection has already been closed. 
    at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:305) 
    at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:329) 
    at org.springframework.jdbc.support.SQLErrorCodesFactory.getErrorCodes(SQLErrorCodesFactory.java:214) 
    at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.setDataSource(SQLErrorCodeSQLExceptionTranslator.java:134) 
    at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.<init>(SQLErrorCodeSQLExceptionTranslator.java:97) 
    at org.springframework.jdbc.support.JdbcAccessor.getExceptionTranslator(JdbcAccessor.java:99) 
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:645) 
    at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:680) 
    at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:707) 
    at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:757) 
    at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.query(NamedParameterJdbcTemplate.java:192) 
+1

關於連接已關閉的嵌套SQLException提示代碼或可能的配置問題。請更新與不工作的代碼。 –

回答

0

如果從數據庫中檢索的400行需要一定的時間,我想你打DB連接超時。如果是這樣,如果您正在使用資源池,請增加connectionTimeout。您也在調試代碼時發生超時。

也可能是超時在數據庫端。在這種情況下,您必須調整數據庫超時參數。