Trying to use JFreeChart using JSP/Servles; issues with JDBCCategoryDataset and CategoryDataset

后端 未结 1 1960
灰色年华
灰色年华 2020-12-07 06:01

i am trying to connect to a database and execute a query in a servlet. I am following this example JFreeChart Example. If you look at the readData() method, it

相关标签:
1条回答
  • 2020-12-07 06:14

    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.

    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; 
     } 
    
    0 讨论(0)
提交回复
热议问题