jdbcTemplate使用總結1
SqlRowSet rs = jdbcTemplate.queryForRowSet(sql, params);
Tips1: jdbcTemplate有很多的ORM化回撥操作將返回結果轉為物件列表,但很多時候還是需要返回ResultSet,Spring有提供一個類似ResultSet的,實現JDBC3.0 RowSet介面的 Spring SqlRowSet。兩個類似的類,RowSet簡單的封裝了一層resultset,使用起來可能有點區別,使用jdbcTemplate.queryForRowSet()遇到UncategorizedSQLException:Invalid precision value. Cannot be less than zero的異常,原因:
it was caused by Oracle's drivers not correctly supporting the CachedRowSet interface.
解決辦法是creating an ResultSetExctractor class that implements ResultSetExtractor and used that to get an OracleCachedRowSet implementation of SqlRowSet. To use this you will need to include the oracle driver jar in your project (used ojdbc5.jar).
Tips2:.注意jdbcTemplate儘量只執行查詢操作,莫要進行更新,否則會破壞Hibernate的二級快取體系。
Tips1: jdbcTemplate有很多的ORM化回撥操作將返回結果轉為物件列表,但很多時候還是需要返回ResultSet,Spring有提供一個類似ResultSet的,實現JDBC3.0 RowSet介面的 Spring SqlRowSet。兩個類似的類,RowSet簡單的封裝了一層resultset,使用起來可能有點區別,使用jdbcTemplate.queryForRowSet()遇到UncategorizedSQLException:Invalid precision value. Cannot be less than zero的異常,原因:
it was caused by Oracle's drivers not correctly supporting the CachedRowSet interface.
解決辦法是creating an ResultSetExctractor class that implements ResultSetExtractor and used that to get an OracleCachedRowSet implementation of SqlRowSet. To use this you will need to include the oracle driver jar in your project (used ojdbc5.jar).
Tips2:.注意jdbcTemplate儘量只執行查詢操作,莫要進行更新,否則會破壞Hibernate的二級快取體系。
相關文章
- JdbcTemplate的使用JDBC
- EXT.NET 使用總結(1)
- SpringBoot使用JdbcTemplateSpring BootJDBC
- 總結1
- 零散知識點總結(1) Gradle 使用配置總結Gradle
- springboot整合使用JdbcTemplateSpring BootJDBC
- JDBC總結1JDBC
- php總結_1PHP
- jquery 總結(1)jQuery
- jdbcTemplate 獲取資料表結構JDBC
- JdbcTemplateJDBC
- Spring JdbcTemplate之使用詳解SpringJDBC
- Spring 系列之jdbcTemplate的使用SpringJDBC
- Android總結1Android
- [php]php總結(1)PHP
- OOP 1~3總結OOP
- 抽取JDBCTemplateJDBC
- shell學習總結-1
- 1、ajax、axios總結iOS
- Redis學習總結1Redis
- NODE Stream流總結(1)
- oracle自測總結1Oracle
- 學習心得總結(1)
- bootstrap學習總結1boot
- RMAN 總結篇 1 - (轉)
- SVN使用總結
- Git 使用總結Git
- Vuex使用總結Vue
- Toolbar使用總結
- Gson使用總結
- Ajax使用總結
- HelloCharts 使用總結
- Nginx使用總結Nginx
- VUE 使用總結Vue
- npm使用總結NPM
- 前端this使用總結前端
- kvm使用總結
- jmeter 使用總結JMeter