Question

I'm trying to count the number of times multiple id's appears in a database table, then using them numbers to put into a JFreeChart. Im currently unaware how to do this and cannot find code online to do this.

Was it helpful?

Solution

Well I'm certainly no expert but I recently did something similar in an application. You can hardcode the required SQL query strings into your application code and thus, retrieve the required data from your database. You will need a database connector for this. The connector you need depends on what language you are writing code in and what database you are using.

You will receive resultsets where the data from your database is returned as Strings. This includes data that was stored in your database in numeric format so you may need to cast the strings to another format if thats what you require. You feed the result set into a collection structure such as 'ArrayList' (if you are using Java for example). You said you are trying to count id's so you could use searching methods for whatever collection you use to tell you whether the strings in the collection are duplicates, you may need to use a a set (a collection which cant have duplicates) for comparison purposes. There's not that much detail in your question but this should help, just count the duplicates in your collection and keep track of the numbers.

At the end if this you will have a collection of numerical values so you simply feed this to a class which imports the required JFreeChart modules and uses the data to create a chart.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top