Fetching data in small units instead of fetching at a time - java

I'm currently working on a Struts 2 application with Spring as backend with MySQL database.
Right now fetching 1000+ rows on page load.
I'm using tablesorter jquery plugin for displaying the results,sorting on click and pagination purpose.
But the page is taking lot of time to load and also it hangs in IE !!
Is there any easier way to do this like fetching required data from database as and when the user makes the selection like fetch first 10 rows,sorting data,etc.
Any ideas to make the application work faster are welcome !!

I couldn't tell from the docs if the plugin supported server-side paging or not, but that'd be one thing to consider. It was unclear if its paging plugin had any options for this.
Does the plugin's example with a thousand students crash under the same circumstance?

Related

Rookie question - Can I write a script that executes actions for our internal cloud software?

I work for a big global company (100 000 employees) and we have an internal software (its a database), this service/softwareh can be accessed from all employes via their internet browsers.
I need to change about 200 names in this databas and it is a VERY repetative work which takes time due to the cloud service is sometimes very slow. It usually takes 20 minutes to change one name... and I need to do 200 names!!
I have asked if its possible to just write a script that picks up my information from an excel sheet, then open ups the internet explorer, go to the site, click on all the correct buttons and paste the correct values.
The answer I got was "It is not possible to write a script to alter the database, you would need to go via IT department and via the correct programmers". But I assume that is if I want to superbig mass-update the database? I just want to get rid of the repetative task so I dont need to sit and wait 20 minutes x 200 names.
I guess my question is: Is it possible to write a script that performs actions via internet explorer EVEN IF ITS AN INTERNAL SOFTWARE/CLOUD SERVICE we are visiting?
Please - Im very very new to coding, as you might tell.
Welcome to stack overflow! It's definitely possible to automate those sorts of tasks using scripts, but if you're going down that route I would suggest that automating via internet explorer isn't the best option. Perhaps your IT team could look into creating a tool to access and modify the database directly instead? That would likely be much faster and less convoluted to set up than automating via a web interface.
However, if you're set on using a web browser to automate tasks I would suggest that you start by looking into basic javaScript tutorials and jquery to get started with web manipulation (jquery is an addon library for javascript that lets you set up interactions with web page elements in a friendlier way)! Using javascript you can write scripts to simulate button clicks and enter text values, which sounds like what you're looking for.

Java Temporary file for Memory management

I have a huge data that has to be displayed in a page retrieved from database table. The table is regularly updated with new data and page has to display the latest data whenever refreshed. Since, the page is loaded with heavy loads of data it takes time to load (2-3minutes) and sometime it suffers from only displaying white page.
So, what I need to do is create a temporary file in server which stores this data from database and the page will extract info from this file. This file should be reloaded with new data in each 10-15 minutes so that till 15 mins page displays the old data but after 15 minutes if page is refreshed it shows the new data.
Hope my problem will be solved with the above idea but I am only limited to above theory. Please provide me solution how it can be done and any other better idea than the above. if any java code sample that would be great to solve my problem.
Thanks
Now you are propably using a lightweight webserver (guessing from the fact you are talking about pages loading white)
But if were using some java ee application server like glassfish, you could have a scheduled task running every 15minutes that loads the data and stores it into a file.
http://docs.oracle.com/javaee/6/tutorial/doc/bnboy.html
Maybe Quartz is the answer for you:
Scheduled task in a web application?
Or maybe you are not using a webserver/appserver at all and my answer completly invalid.

How to write a simple gridview in java?

I wrote sql but it takes more time when execute it in jsp. And I want to make faster it. Will grid view make the page faster?
I'm junior in Java. I researched in google but didn't find clear sample about gridview. Can u help me?
I understand you have a web based application backed by the DB.
Note that gridview is not something offered by Java, instead you can create tables by using your web frameworks and render data there.
You say, it takes a lot of time to execute an SQL when running withing JSP. Where the time goes?
Running the SQL itself? Maybe creating a JSP or transmitting it to the client browser in an Html form, or even maybe the rendering of your table in browser?
You should detect the bottleneck in order to understand what you're going to fix
Consider to use profiler and see (at least on server vm) where the time goes.
I think JVisualVM will suit your needs here.
Hope this helps
I would have done this task using following steps
Create one servlet.
Connect to the database and fetch the data which we have to display.
Create a list and keep the data in list it.
Set the list in request and forward the control to JSP.
On JSP, use DisplayTag to show the data in grid form.
Hope this helps you.

How do I handle large resultsets in Crystal Reports using Java?

Problem Definition
I have a performance problem displaying large/huge resultset of data on a crystal report. The report takes about 4 minutes or more depending on the resultset size.
How do you handle large resultsets in Crystal Reports without a performance issue?
Environment
Crystal Reports XI
Apache WebSvr 2.X
Jboss 4.2.3
Struts
Java Reporting Component (JRC)
Crystal Report Viewer (CRV)
Firefox
Details
I use the CRXI thick client to build my report (.rpt) and then use it in my webapplication (webapp) under Jboss.
User specifies the filter criteria to generate a report (date range etc) and submits the request to the webapp. Webapp queries the database, gets a "resultset".
I initialize the JRC and CRV according to all the specifications and finally call the "processHttpRequest" method of Crystal Report Viewer to display the report on browser.
So.....
Request received to generate a report with a filter criteria
Query DB to get resultset
Initialize JRC and CRV
finally display the report by calling
reportViewer.processHttpRequest(request, response, request.getSession().getServletContext(), null);
The performance problem is within the last step. I put logs everywhere and noticed that database query doesnt take too long to return resultset. Everything processes pretty quickly till I call the processHttpRequest of CRV. This method just hangs for a long time before displaying the report on browser.
CRV runs pretty fast when the resultset is smaller, but for large resultset it takes a long long time.
I do have subreports and use Crystal report formulas on the reports. Some of them are used for grouping also. But I dont think Subreports is the real culprit here. Because I have some other reports that dont have any subreports, and they too get really slow displaying large resultsets.
Solutions?
So obviously I need a good solution to this generic problem of "How do you handle large resultsets in Crystal Reports?"
I have thought of some half baked ideas.
A) Use external pagination and fetch data only for the current page being displayed. But for this, CRXI must allow me to create my own buttons (previous, next, last), so I can control the click event and fetch data accordingly. I tried capturing events by registering event handler "addToolbarCommandEventListener" of CRV. But my listener gets invoked "after" processHttpRequest method completes, which doesnt help.
Some how I need to be able to control the UI by adding my own previous page, next page, last page buttons and controlling it's click events.
B) Have CRXI use a jquery type of functionality, to allow browser side page navigation. So maybe the first time it'll take 5 mins to display the report, but once it's displayed, user can go to any page without sending the request back to server.
C) Try using Crystal Reports 2008. I'm open to using this version, but I couldnt figureout if it has any features that can help me.
D) Use BIRT or JasperReports, since they apparently have the ability to handle large datasets, by caching a part of the dataset on disk etc...
E) Will using the Crystal Reports Servers like cache server, application server etc help in any way? I read a little on the Crystal Page Viewer, Interactive Viewer, Part Viewer etc....but I'm not sure if any of these things are going to solve the issue.
I'd appreciate it if someone can point me in the right direction.

Plugin or module for filtering/sorting a large amount of data?

I have a rather large amount of data (100 MB or so), that I would like to present to a user. The format of the data is similar to the following...
Date Location Log File Link
03/21/2010 San Diego some_log.txt http://somelink.com
etc
My problem is that I would like to have some nice/slick way for the user to filter the information. Unfortunately, because there is so much of it, the jQuery Table Filter plugin does not work (crashes the browser). I was wondering if there is a nice solution or if I have to simply do the filtering on the server end and have a bland pull-down menu / select-box interface for the client to use.
100MB is pretty huge. You don't want to transfer all that data at once to the client side on a single request and then do the paging/filtering/sorting actions over there. It would take ages to transfer it and it would eat all the client's memory. Rather do that entirely at the server side on every request using SQL powers. SQL can do it much more efficient than Java/JavaScript. I've posted a similar answer with more technical details and code examplpes before here.
Use paging. (Maybe a little ajax).
If the browser has Google Gears installed for its DB API or supports HTML5's Web SQL Database (e.g. Opera 10.5+), you can import all the data into a client-side SQL database and perform the sorting+paging queries with SQL.

Categories

Resources