2014-11-15 58 views

回答

2

因爲JDBCCategoryDataset實現了CategoryDataset接口,所以在作業中不需要強制轉換:CategoryDataset data = readData();從下面列出的readData()的變體中可以看到下面的圖表。我懷疑你有另一個問題。

chart

private CategoryDataset readData() { 

    JDBCCategoryDataset data = null; 
    Connection con; 
    try { 
     con = DriverManager.getConnection("jdbc:h2:mem:test", "", ""); 
     data = new JDBCCategoryDataset(con); 
     String sql = "select TYPE_NAME, PRECISION " 
      + "from INFORMATION_SCHEMA.TYPE_INFO " 
      + "where PRECISION BETWEEN 1 AND 12"; 
     data.executeQuery(sql); 
     con.close(); 
    } 
    … 
    return data; 
}