I want to generate a code that will automatically take the poll-id..of which the user wishes to view the result of that poll. there's the code:using mysql & java & another thing i wish to use this on a jsp page:

package votepiepack;
  import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.*;
  import org.jfree.chart.*;
  import org.jfree.data.jdbc.*;
  import org.jfree.data.general.*;
  public class votepie {
               * @param args
              private PieDataset readData() {
                          JDBCPieDataset data = null;
                          String url = "jdbc:mysql://localhost/vote";
                          Connection con;
                          try {
                          catch (ClassNotFoundException e) {
                          System.err.print("ClassNotFoundException: ");
                          try {
                          con = DriverManager.getConnection(url, "vote", "vote001");
                          data = new JDBCPieDataset(con);
                          String sql = "SELECT option_text, counter FROM VOTE_VOTES WHERE poll-id=1;";
                          catch (SQLException e) {
                          System.err.print("SQLException: ");
                          catch (Exception e) {
                          System.err.print("Exception: ");
                          return data;
              public static void main(String[] args) {
                          // TODO Auto-generated method stub
                          votepie pd = new votepie();
                          //creating the chart
                          JFreeChart chart = ChartFactory.createPieChart(
                                                  "Sample Pie Chart",
                                                  true, // legend?
                                                  true, // tooltips?
                                                  false // URLs?
                                                  // create and display a frame...
                                                  ChartFrame frame = new ChartFrame("First", chart);

as you can see I can view only 1 result at a time.

String sql = "SELECT option_text, counter FROM VOTE_VOTES WHERE poll-id=1;";

but how is it possible to capture the poll-id on which the user wishes to click & show the result of that poll....note, that the number of polls is not constant, it can increase as any number of polls can be created. please suggest ...thanks

Why did you start a new thread? Because you didn't like the answers you were getting?

Please, do not multi-post in this manner. Stick with the original thread.

actually 1st I posted this on java forum then someone told me to post the question into jsp-forum. by that time s.o.s had moved my original post in here......anyways can you help regarding the query?????

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.