Create graphs and charts in Java Swing application using MySql ResultSet data - java

I have heard of JfreeChart but is there any general steps for using data returned from an SQL query to create graphs and chart.
I have an application that shows as a menu option "Analytic's", this Jframe window uses complicated query to retrieve data using business logic but i want to then display this data in a more viable way (rather than a long Jtable result). How can i filter my data and create a graph for the user to analyze?

Check java2s.com/Code/Java/Chart/CatalogChart.htm for a lot examples.

Generally you can fill your own dataset based on your ResultSet. But if you are query is returning results close enough to what you are loading into your dataset you can just use the JDBCCategoryDataset from JFreeChart.

Since you are in search... I think that there is no better tool for designing and generating reports and graphs from your database than iReport. It offers a very consistent GUI, and gives you all support necessary to start creating business graphs from your database data.
The produced report is dynamic. Can be embedded into any application. The reports can be exported as PDF, XML, XHTML, .doc, .odt and more ways. One can pass variables to the report at run-time like from-to Dates, code-id's etc.
iReport is built on top of JasperReports. It is free and open source.
Let me make also clear that i am not in any way affiliated with iReport! :-)

Related

Data Validation through selenium scripts between reports and backend database

Problem Statement: I am having a report that is view-able from an online portal and the data is populated from the data-mart using various stored procs for this report.
I want to validate the report's data from the online screen against the SQL queries that I have developed for testing. The problem is that the report is having many fields say about 20 different fields and 2 or 3 sections. For populating the different sections and fields we are having individual queries or stored procs.
Now the major challenge that I am facing is that I could get the data from the online screen easily but am not sure how to get the data from the backend for the validations.
I tried writing a macro for the same and it returned the results but then to format the results in the form of the report is becoming a cumbersome job. And this needs to be done for around 40 + reports.
Any ideas of tackling these kind of situations would really help me out.
Thanks in advance.
For generalization we can think of the scenario as a report testing scenario where in we will view the reports from online screen and validate its data from the backend by using custom queries developed by the testing team based on the logics( and not using the developers queries) so that an independent validation can be carried through.
And this whole testing portion would run as a part of the automated regression suite being developed for the portal with the help of selenium and java.
Your problem statements indicates that you are attempting to verify a specific reports data, as opposed to the display of that data in the GUI. For this problem I would recommend that you eliminate the GUI from the test, and use the product's API to retrieve the report content. From this, you could possibly store the results as a SQLite table, for example, then write code to compare table contents with the results you obtain with your comparison queries.
This approach will eliminate the need to process the GUI content, allowing you to focus on the task at hand, verifying the report content.
By the way, if your GUI does a lot of additional processing of the report data (e.g. filtering, sorting, etc.), you'll need to have a different set of test cases to verify that functionality. It's important to conceptually differentiate that from the data content.

Java Data base query/update for large amount of data

What is the best way to implement the following scenario?
I need to call/query a data base table containing millions of records from a java application. Then for each records in the table, my application should call a third party API and get a status field as response. Then my application should again update each row in the table with the information (status) from the API.
Note - I am trying to figure out a method to do this in the best possible way. I understand that querying all the records together is not the best way forward.
Do not try to eat the elephant in one bite. Chunk it. Heard of pagination? Use it. See here: MySQL pagination without double-querying?
you can use oracle feature such as SQL loader, Data pumping Called via JDBC or script..
Databases are not designed to update millions of records via Java API repeatedly. This can take many minutes. If this is not enough, you may need to use a dataset embedded in Java (either caching or replacing your database)

XML or Database for Auto form generation

So I'm creating a program that auto generates forms for data entry. The form is created by a user (its a simple table setup with the ability to merge cells). Some of the cells contain text views, others contain text inputs (all based on how the user draws it).
This form is then sent to another application that draws it back out. I was wondering what the best method is to represent the form. I though either use XML to represent the form or use a database that would basically function as a grid and row 1 column 1 in the database would match the form cell row 1 column 1 and so on (kind of an odd way to use a database).
The form creation program is made in C++ and the form regeneration program is created in Java.
Is there an even better way to do this?
Thanks,
I am also thinking the same thing because I am in to creating dynamic forms for my framework to. So I will share some thoughts with you. Using database to add new forms like adding a record in one table that specifies the form and its fields in another having the ability to select it's field types to, or creating one table for each form and each time create a new table or altering its fields (sound messy).. or create a folder with a bunch of xmls that are used for the structure of your forms?
When it comes to database:
Your application is stricted with a specific database application
like sql server 2008 or mysql or mysqli or oracle etc.
Your application is causing network traffic, not that bad but it is
doing it eveytime you need to create or use a form.
You need a panel that creates those forms using the database, and
can be accessed if its web even from your mobile.
When it comes to XML:
Your application is free from database version restrictions.
you need the impersonator to have the right to create files in a
spesific directory in your frameowork.
You don't need a panel even though you can create one, because XML are human readable files. So you can make one while eating your dinner and serve it to your system,
and wala, you have your form generated.
These are my thoughts for now.
How about the methods that will be used in the form? will those also be dynamic? How can you specify what calls what? this is also what you need to take in account.
I think that XML is a much better choice here. Using database as a grid could be more of a headache than needed. You will have to deal with all the problems related to having the database and not really get any benefits of the database. The industry decides to go with xml more often than not as well (xbrl being one example).

Form Layout style

As we know Data Blocks style layout in oracle can view in 2 way:
1. FORM
2. TABULAR
I want to know in Java is there any component have same behavior? I mean I want to have table(in form style) same as a data blocks that customer enter his data than after he press save all data go to database, is it possible or not?
Unlike .NET, Java doesn't have a UI component which can be connected directly to a database table for editing.
I'm also not aware of a framework which adds this. There are DB tools like SQuirreL SQL which have inline table editing.
There are lots of frameworks to map DB tables to Java POJOs (Hibernate, for example) but that means you need to define Java mappings for your database tables. With that, you can use UI frameworks like Metawidget to create an editor.

Lightweight Java solution for creating views on large data

I need to create a Java (J2EE) application that allows people to generate "views" on large CSV/TSV tabular data. Views might include things like: pagination through the data, sorting, filtering, pivoting and perhaps charting.
My current thinking is to load the data into temporary tables in a database, use SQL to perform the view tasks and then discard the tables.
Can someone recommend a better approach for this that is also fast?
My constrains are:
This is a real-time transaction, so Hadoop/Hive is not an option
Fast response times are important
I would like to be able to do this in a stateless way where individual requests describe the view (but not at the cost of performance)
I would like to not have to hand-code view generation, hence the preference for SQL databases.
Answering my own question. I find that HSQL does exactly what I need. Looks like Text Tables in HSQL are what I would use to create views the way I need.

Categories