且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

尝试通过 JSP/Servles 使用 JFreeChart;JDBCCategoryDataset 和 CategoryDataset 的问题

更新时间:2023-02-06 16:22:43

因为 JDBCCategoryDataset 实现了CategoryDataset 接口,赋值时不需要强制转换:CategoryDataset data = readData(); 我从下面概述的 readData() 的变体中得到以下图表.我怀疑你有另一个问题.

Because JDBCCategoryDataset implements the CategoryDataset interface, no cast should be required in the assignment: CategoryDataset data = readData(); I get the following chart from the variation of readData() outlined below. I suspect that you have another problem.

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