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 storage from there it will show in the output .Is it fine .
Or is there something related to J2C
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
Hope this helps.