急!!JFreeChart The method createPieChartis not applicable 的问题

问题描述

刚学JFreeChart从网上找了实例但是碰到这样这样的问题希望高手指点谢谢代码:<%@pagecontentType="text/html;charset=GB2312"%><%@pageimport="org.jfree.chart.JFreeChart,org.jfree.chart.ChartUtilities,org.jfree.chart.ChartFactory,org.jfree.data.general.DefaultPieDataset,org.jfree.data.general.PieDataset,java.sql.*"%><html><body>  <%Connectioncon=null;//数据连接对象Statementsql=null;//SQL语句对象ResultSetrs=null;//结果记录集对象StringdataName[]=newString[]{"","","",""};//显示数据系列intdataValueCount[]={0,0,0,0};//数据系列对应的值Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");con=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=test","sa","12345");sql=con.createStatement();rs=sql.executeQuery("select'0-30岁'asuserage,count(*)asusercountfromuserTablewhereuser_age>=0anduser_age<30"+"unionselect'30-50岁'asuserage,count(*)asusercountfromuserTablewhereuser_age>=30anduser_age<50"+"unionselect'50-70岁'asuserage,count(*)asusercountfromuserTablewhereuser_age>=50anduser_age<70"+"unionselect'70岁以上'asuserage,count(*)asusercountfromuserTablewhereuser_age>=70");intj=0;while(rs.next()){dataName[j]=rs.getString("userage");dataValueCount[j]=rs.getInt("usercount");j++;}DefaultPieDatasetpieDataset=newDefaultPieDataset();for(inti=0;i<dataName.length;i++)pieDataset.setValue(dataName[i],dataValueCount[i]);StringtitleString="用户年龄阶段分布统计图";//图的标题JFreeChartchart=ChartFactory.createPieChart(titleString,pieDataset,true,true,false);ChartUtilities.writeChartAsJPEG(response.getOutputStream(),chart,500,300);%></body></html>显示错误:exceptionorg.apache.jasper.JasperException:UnabletocompileclassforJSP:Anerroroccurredatline:35inthejspfile:/pie2.jspThemethodcreatePieChart(String,PieDataset,boolean,boolean,boolean)inthetypeChartFactoryisnotapplicableforthearguments(String,DefaultPieDataset,boolean,boolean,boolean)32:pieDataset.setValue(dataName[i],dataValueCount[i]);33:StringtitleString="用户年龄阶段分布统计图";//图的标题34:35:JFreeChartchart=ChartFactory.createPieChart(titleString,pieDataset,true,true,false);36:ChartUtilities.writeChartAsJPEG(response.getOutputStream(),chart,500,300);37:38:%>

解决方案

解决方案二:
代码中红色部分为错误行

时间: 2024-09-21 17:22:12

急!!JFreeChart The method createPieChartis not applicable 的问题的相关文章

[@Controller]2 详解@RequestMapping

[@Controller]2 详解@RequestMapping  (2012-06-14 15:41:06)转载▼ 标签:  spring   requestmapping   it 分类: JavaSpring A.@RequestMapping org.springframework.web.bind.annotation.RequestMapping Annotation for mapping web requests onto specific handler classes and

The method setFilters(InputFilter[]) in the type Editable is not applicable

解决办法: EditText mEdit = (EditText)findViewById(R.id.mEdit); InputFilter[] filters = {new AdnNameLengthFilter()}; mEdit.setFilters(filters); public static class AdnNameLengthFilter implements InputFilter { private int nMax; public CharSequence filter (

JAVA 用JFreeChart绘制K线图 急!急!急!!求高手!

问题描述 protectedstaticOHLCDatasetgetPriceDataSet(Stringsymbol){List<OHLCDataItem>dataItems=newArrayList<OHLCDataItem>();try{//StringstrUrl="http://ichart.finance.yahoo.com/table.csv?s="//+symbol+"&a=8&b=1&c=2009&d=

jsp 中用jfreechart 运行出错 求大神解答 或求折线例子

问题描述 jsp 中用jfreechart 运行出错 求大神解答 或求折线例子 代码如下 DefaultCategoryDataset linedataset = new DefaultCategoryDataset();// 各曲线名称String series1 = ""订单量与时间"";String series2 = ""发生金额与时间""; // DefaultCategoryDataset dataset = ne

javabean-java注入bean的相关问题,求大神帮我看看,感激不尽!急急急。。。。。。

问题描述 java注入bean的相关问题,求大神帮我看看,感激不尽!急急急...... 启动tomcat后报错了严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListenerorg.springframework.beans.factory.BeanCreationException: Error

急!!!!ajax responseText的问题

问题描述 急!!!!ajax responseText的问题 5C 先贴代码 if(new_!=renew_){ alert(""输入的两次密码不同""); return false; }else{ var url= ""<%=basePath%>/system/password/reset1""; var pars =""oldPassword=""+encodeURICo

error-Data Error????????急

问题描述 Data Error????????急 Data error. 说明: 执行当前 Web 请求期间,出现未经处理的异常.请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息. 异常详细信息: System.ApplicationException: Data error. 源错误: 执行当前 Web 请求期间生成了未经处理的异常.可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息. 堆栈跟踪: [ApplicationException: Data err

c#-急!unity导入vuforia包后出现CS1061错误,求大神帮忙看看!

问题描述 急!unity导入vuforia包后出现CS1061错误,求大神帮忙看看! Assets/Vuforia/Scripts/Utilities/VRIntegrationHelper.cs(94,43): error CS1061: Type object' does not contain a definition forApplyCorrectedProjectionMatrix' and no extension method ApplyCorrectedProjectionMat

跳转路径-急求解决,jsp页面中循环生成的form表单,action路径错误

问题描述 急求解决,jsp页面中循环生成的form表单,action路径错误 在jsp页面中用循环生成的form表单,为什么action不是想要的呢,代码贴在下面了 reply=(Map)request.getAttribute("REPLY"); while(rsComment.next()) { // 评论编号 String CId = rsComment.getString("CId"); // 评论人 String name=rsComment.getStr