In my project, I want to display in the pie chart how many institutions each employee registered in the system. The institutions table contains a foreign key with the id of the
You don't need the PreparedStatement
. Use the org.jfree.data.jdbc.JDBCPieDataset constructor that accepts a query "that returns data in two columns, the first containing VARCHAR
data, and the second containing numerical data." You can use the dataset in your ChartFactory
.
JDBCPieDataset ds = new JDBCPieDataset(conn, "SELECT ...");
A complete example is shown here.