开发者

How to display piecharts use datafrom my database

I want to generate a piechart but the image is always empty this is my code (In fact I want to display it on my page test.xhtml but I couldn't so I have tried to display it as image) :

public void PieChart() throws SQLException, ClassNotFoundException
 {

  String query = "SELECT id, pname from issuestatus";
  JDBCPieDataset dataset = new JDBCPieDataset("jdbc:mysql://localhost:3306/jiradb", "com.mysql.jdbc.Driver","root", "root");
   dataset.executeQuery(query);
 JFreeChart chart = ChartFactory.createPieChart("Pie Chart ",dataset, true, true, false);

 try {
 final ChartRenderingInfo info = new 
  ChartRenderingInfo(new StandardEntityCollection());

  final File file1 = new File("C:/Documents and Settings/piechart.png");
  ChartUtilities.saveChartAsPNG( file1, chart, 600, 400, info);
  } catch (Exception e) {
  e.printStackTrace();
  }

}

I have call th开发者_运维问答is method from my page test.xhtml

<p:commandButton ajax="false" action="#{TestAjax.PieChart()}" value="OK"></p:commandButton>

and this error appear:

GRAVE: JDBCPieDataset - unknown data type
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜