2011-07-02 23 views
1

我想生成一個餅圖,但圖像總是空的這是我的代碼(事實上,我想顯示它在我的網頁test.xhtml,但我不能,所以我已經嘗試以顯示它的圖像):如何顯示餅圖使用我的數據庫中的數據

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(); 
    } 

} 

我從我的頁面調用這個方法test.xhtml

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

這個錯誤出現:

GRAVE: JDBCPieDataset - unknown data type 

回答

相關問題