There is a database it contains 2 million records approx in a table . and i ran the query from my java code like this " select * from table" . will it fetch the complete data from the database in the result set . or not . If yes then how it will work i want to learn the working on this retrieveal ,
Please let me know , i have learnt somewhere that it will retrieve the complete data from the database and will store in the temporary开发者_StackOverflow storage from there it will show in the output .Is it fine . Or is there something related to J2C
Here's nearly the same question. How to handle huge result sets from database
You ask if it will fetch the complete dataset. it will. therefore, it's advised to not fetch the whole database. Here's something about where it's saved java - mysql - select query outfile - where is file getting saved
Will it fetch the complete data from the database in the result set
There is no precise answer to it. Its always dependent on the database driver. The result set is an Interface and its implementation is done by a specific database driver. The ResultSet implementation may have its own optimization wherein for smaller set of data, everything is fetched where as for larger datasets, its buffered (or some default paging mechanism). So please refer to the database driver documentation.
There is a standard (at least the javadoc says so) way out to prevent the fetching of large data from database. Set the appropriate fetch size for the JDBC statement as follows java.sql.Statement.setFetchSize()
.
As the java doc
Gives the JDBC driver a hint as to the number of rows that should be fetched from the database when more rows are needed. The number of rows specified affects only result sets created using this statement. If the value specified is zero, then the hint is ignored. The default value is zero.
Hope this helps.
精彩评论