User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 391,558 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,736 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 723 | Replies: 2 | Solved
Reply
Join Date: Nov 2006
Posts: 38
Reputation: apontutul is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
apontutul's Avatar
apontutul apontutul is offline Offline
Light Poster

generating dynamic/runtime query

  #1  
Sep 1st, 2007
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 {
                          Class.forName("com.mysql.jdbc.Driver");
                          }
                          catch (ClassNotFoundException e) {
                          System.err.print("ClassNotFoundException: ");
                          System.err.println(e.getMessage());
                          }
                          try {
                          con = DriverManager.getConnection(url, "vote", "vote001");
                          data = new JDBCPieDataset(con);
                          String sql = "SELECT option_text, counter FROM VOTE_VOTES WHERE poll-id=1;";
                          data.executeQuery(sql);
                          con.close();
                          }
                          catch (SQLException e) {
                          System.err.print("SQLException: ");
                          System.err.println(e.getMessage());
                          }
                          catch (Exception e) {
                          System.err.print("Exception: ");
                          System.err.println(e.getMessage());
                          }
                          return data;
                          }
              public static void main(String[] args) {
                          // TODO Auto-generated method stub
                          
                          votepie pd = new votepie();
                          pd.readData();
                          
                          //creating the chart
                          JFreeChart chart = ChartFactory.createPieChart(
                                                  "Sample Pie Chart",
                                                  pd.readData(),
                                                  true, // legend?
                                                  true, // tooltips?
                                                  false // URLs?
                                                  );
                                                  // create and display a frame...
                                                  ChartFrame frame = new ChartFrame("First", chart);
                                                  frame.pack();
                                                  frame.setVisible(true);
   
              }
   
  }

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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2006
Posts: 1,360
Reputation: masijade is a jewel in the rough masijade is a jewel in the rough masijade is a jewel in the rough masijade is a jewel in the rough 
Rep Power: 8
Solved Threads: 117
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Virtuoso

Re: generating dynamic/runtime query

  #2  
Sep 3rd, 2007
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.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote  
Join Date: Nov 2006
Posts: 38
Reputation: apontutul is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
apontutul's Avatar
apontutul apontutul is offline Offline
Light Poster

Re: generating dynamic/runtime query

  #3  
Sep 3rd, 2007
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?????
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JSP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JSP Forum

All times are GMT -4. The time now is 9:53 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC