简体   繁体   中英

Scrollable resultset in spring jdbc

I am executing a query and want to capture results in a String two dimensional array. We are using NamedParameterJdbcTemplate to execute query. To populate results into 2 dimensional String array, I need to know number of rows and number of columns.We get number of columns from resultset meta data.

How to find number of rows? How to use scrollable result set in spring jdbc

Why not try other alternative data structures for a 2D array like following?

  • List of lists where each element in outer list is a record and each element in the inner list is a column.
  • List of maps where each element in list is a record and each pair in the map is a tuple of column name, column value

Then you would be generically fetching all the columns you selected, using the ResultSetMetaData and you don't need to know the number of rows upfront.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM