Note that there are some explanatory texts on larger screens.

plurals
  1. POFetching unique Value and no. of times of the Value
    primarykey
    data
    text
    <p>In a (using mysql)table one of my column(i.e. colour) is like :</p> <pre><code>|Color| ====== |Red | |Blue | |Green| |Red | |Green| |Green| |Red | |Red | </code></pre> <p>After establishing,jdbc connection in my current jsp page: I'm trying to show the value in a pie chart(it's wriien in jscript,where I'll putting the value from mysql) like : </p> <pre><code>|Color|no. of Times| ==================== |Red | 4 | |Blue | 1 | |Green| 3 | </code></pre> <p>Buy I am not able to put values into the graph(I guess there is problem in by code):</p> <pre><code>&lt;% Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc:mysql://localhost/apps","root","root"); Statement stmt = con.createStatement(); String sql2="select distinct(color) as COLOR from user_management order by device;"; ResultSet rs2 = stmt.executeQuery(sql2); String s = rs2.getString("color"); while(rs2.next()){ String device = rs2.getString("color"); List&lt;String&gt; list=new ArrayList&lt;String&gt;(); list.add(device); } // I guess here will be some code for device value in String, say "s" String sql1 = "select count(case when color='"+s+"' then 1 end) as COLOR from user_management"; ResultSet rs1 = stmt.executeQuery(sql1); System.out.println(sql1); %&gt; </code></pre> <p>then putting the resultset in piechart table </p> <pre><code>&lt;table id="chartData"&gt; &lt;% while(rs2.next()){ %&gt; &lt;% while(rs1.next()){ %&gt; &lt;tr&gt; &lt;th&gt;DEVICE&lt;/th&gt;&lt;th&gt;NUMBER&lt;/th&gt; &lt;/tr&gt; &lt;tr style="color: #0DA068"&gt; &lt;td&gt;&lt;%= rs2.getString("device")%&gt;&lt;/td&gt;&lt;td&gt;&lt;%= rs1.getString(1)%&gt;&lt;/td&gt; &lt;/tr&gt; &lt;% } %&gt; &lt;% } %&gt; &lt;/table&gt; </code></pre> <p>Any inputs that how to fetch the column value in a chart where color-name as well as no. of color happens at a same time.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload