Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Best way to access large amount of data using JDBC  RSS feed

 
B Bhutta
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everybody,
One of my application is accessing mainframe to access data using JDBC but the number of records I am getting could be in thousands. Whereas I have to show only upto 50 records on a JSP. My question is how I can handle that much amount of data in a result set as putting such a big result set in a session is not a good idea. Any information or a link will be helpful. Thanks for the help.
 
parag Chatterjee
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you need to show only 50 records give a check while u r running the Resultset loop using the rowCount() method of the Resultset so that all the records u will not extract from the database.
I am actually not very sure whether this answer suits to your requirement.Pl. let me knwo.
regards,
Parag
Originally posted by Babar:
Hi Everybody,
One of my application is accessing mainframe to access data using JDBC but the number of records I am getting could be in thousands. Whereas I have to show only upto 50 records on a JSP. My question is how I can handle that much amount of data in a result set as putting such a big result set in a session is not a good idea. Any information or a link will be helpful. Thanks for the help.
 
Suresh Selvaraj
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You can restrict the number of rows returned by setting the max rows returned in a Prepared Statement.
Example:
PreparedStatement ps = null;
ps=con.prepareStatement(sqlQuery);
ps.setMaxRows(50);
Now the number of rows returned is set to 50.
Suresh Selvaraj
 
Arijit Ghosh
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it advisable to use direct Session to JDBC for retreiving large data ? I am using JBoss.
 
Asanka Nanayakkara
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
You can use SQL statement instead of java and JDBC options
SELECT * FROM (SELECT a.*,rownum rnum FROM(SELECT * FROM "table_Name")a WHERE rownum <= 10)WHERE rnum > 0
you keep on increasing the row number variables when each time you access your database for next record set.
Regards
Asanka
Note: this will increase your application performance too
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!