Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Multiple queries to generate reports on mysql data

843859Jun 19 2007 — edited Jun 30 2007
Hi all!

I am looking for some advice.
I plan to generate pdf reports on the following:

1.Gender count of total applicant pool = M/F.
2. How many are freshmen, sophomore, etc...
3. How many applications are complete
4. total number of applicants for the year. This will be plotted on an x-y graph for each year.

Should I store these individual values in a table like or pull the data from the db on the fly?
Im using itext with jfree. Here's a sample

public static void convertToPdf(JFreeChart chart, int width, int height, String filename) {
// step 1
Document document = new Document(new Rectangle(width, height));
try {
// step 2
PdfWriter writer;
writer = PdfWriter.getInstance(document, new FileOutputStream(filename));
// step 3
document.open();
// step 4
PdfContentByte cb = writer.getDirectContent();
PdfTemplate tp = cb.createTemplate(width, height);
Graphics2D g2d = tp.createGraphics(width, height, new DefaultFontMapper());
Rectangle2D r2d = new Rectangle2D.Double(0, 0, width, height);
chart.draw(g2d, r2d);
g2d.dispose();
cb.addTemplate(tp, 0, 0);
}
catch(DocumentException de) {
de.printStackTrace();
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
// step 5
document.close();
}

/**
* Gets an example barchart.
* @return a barchart
*/
public static JFreeChart getBarChart() {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.setValue(40, "hits/hour", "index.html");
dataset.setValue(20, "hits/hour", "download.html");
dataset.setValue(15, "hits/hour", "faq.html");
dataset.setValue(8, "hits/hour", "links.html");
dataset.setValue(31, "hits/hour", "docs.html");
return ChartFactory.createBarChart("Popularity of iText pages",
"Page", "hits/hour", dataset,
PlotOrientation.VERTICAL, false, true, false);
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 28 2007
Added on Jun 19 2007
3 comments
166 views