Rrugemalira
asked on
CEWOLF and jfreeChart: DefaultCategoryDataset method addValue()
EVEN THOUGH I HAVE THE FOLLOWING DECLARED:
import org.jfree.data.category.Ca tegoryData set;
import org.jfree.data.category.De faultCateg oryDataset ;
import de.laures.cewolf.DatasetPr oduceExcep tion;
import de.laures.cewolf.DatasetPr oducer;
import de.laures.cewolf.links.Cat egoryItemL inkGenerat or;
import de.laures.cewolf.tooltips. CategoryTo olTipGener ator;
AND THE JAR FILES IN THE CORRECT DIRECTORY
root /web/WEB-INF/lib
DefaultCategoryDataset hbDataset = new DefaultCategoryDataset();
i = 0;
for (i = 0; i < TOTAL_COUNT; i++) {
hbDataset.addValue(i, numInGroup[i], numZD[i]);
}
return hbDataset;
GIVES THE FOLLOWING ERROR:
cannot find symbol
symbol: method addValue(int, int, java.lang.String)
location: class org.jfree.data.category.De faultCateg oryDataset
Kindly help identify where the problem lies.
import org.jfree.data.category.Ca
import org.jfree.data.category.De
import de.laures.cewolf.DatasetPr
import de.laures.cewolf.DatasetPr
import de.laures.cewolf.links.Cat
import de.laures.cewolf.tooltips.
AND THE JAR FILES IN THE CORRECT DIRECTORY
root /web/WEB-INF/lib
DefaultCategoryDataset hbDataset = new DefaultCategoryDataset();
i = 0;
for (i = 0; i < TOTAL_COUNT; i++) {
hbDataset.addValue(i, numInGroup[i], numZD[i]);
}
return hbDataset;
GIVES THE FOLLOWING ERROR:
cannot find symbol
symbol: method addValue(int, int, java.lang.String)
location: class org.jfree.data.category.De
Kindly help identify where the problem lies.
ASKER
Hello shivaspk,
I still get the same error:
cannot find symbol
symbol: method addValue(int, int, java.lang.String)
location: class org.jfree.data.category.De faultCateg oryDataset
for the line
hbDataset.addValue(i, result.getInt(1), result.getString(2));
Below is the class
/*
* SectorCharts.java
* Created on April 26, 2006, 1:21 PM
*
*/
import java.io.*;
import java.net.*;
import java.util.*;
import java.sql.*;
import javax.sql.*;
import javax.naming.*;
import java.util.Date;
import java.util.Map;
import org.apache.commons.logging .Log;
import org.apache.commons.logging .LogFactor y;
import java.io.Serializable;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import org.jfree.data.category.Ca tegoryData set;
import org.jfree.data.category.De faultCateg oryDataset ;
import de.laures.cewolf.DatasetPr oduceExcep tion;
import de.laures.cewolf.DatasetPr oducer;
import de.laures.cewolf.links.Cat egoryItemL inkGenerat or;
import de.laures.cewolf.tooltips. CategoryTo olTipGener ator;
/**
*
* This class produces a Dataset containing sector counts for provinces.
*
* @author mwijage
*
*/
public class SectorCharts implements DatasetProducer, Serializable {
public Object produceDataset(Map params) throws DatasetProduceException {
try {
Connection conn = DriverManager.getConnectio n(
"jdbc:mysql://localhost/fa rmsDB","mw ijage", "kabale123");
String sql = new String("SELECT count(*), secteur FROM address GROUP BY secteur");
PreparedStatement ps = conn.prepareStatement(sql) ;
ResultSet result = null;
result = ps.executeQuery();
DefaultCategoryDataset hbDataset = new DefaultCategoryDataset();
int i=0;
while (result.next()) {
hbDataset.addValue(i, result.getInt(1), result.getString(2));
i++;
}
result.close();
ps.close();
conn.close();
return hbDataset;
}
catch (SQLException se) {
throw new RuntimeException(se);
}
}
/**
*
* Returns a unique ID for this DatasetProducer
*/
public String getProducerId() {
return "PageViewSecteurData DatasetProducer";
}
/**
* Checks whether curent chart image has expired.
*
* @param params Parameters passed in Request
* @param since Date used for determining expiration
* @return Boolean indicating if Dataset has expired
*/
public boolean hasExpired(Map params, java.util.Date since) {
return false;
}
}
I still get the same error:
cannot find symbol
symbol: method addValue(int, int, java.lang.String)
location: class org.jfree.data.category.De
for the line
hbDataset.addValue(i, result.getInt(1), result.getString(2));
Below is the class
/*
* SectorCharts.java
* Created on April 26, 2006, 1:21 PM
*
*/
import java.io.*;
import java.net.*;
import java.util.*;
import java.sql.*;
import javax.sql.*;
import javax.naming.*;
import java.util.Date;
import java.util.Map;
import org.apache.commons.logging
import org.apache.commons.logging
import java.io.Serializable;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import org.jfree.data.category.Ca
import org.jfree.data.category.De
import de.laures.cewolf.DatasetPr
import de.laures.cewolf.DatasetPr
import de.laures.cewolf.links.Cat
import de.laures.cewolf.tooltips.
/**
*
* This class produces a Dataset containing sector counts for provinces.
*
* @author mwijage
*
*/
public class SectorCharts implements DatasetProducer, Serializable {
public Object produceDataset(Map params) throws DatasetProduceException {
try {
Connection conn = DriverManager.getConnectio
"jdbc:mysql://localhost/fa
String sql = new String("SELECT count(*), secteur FROM address GROUP BY secteur");
PreparedStatement ps = conn.prepareStatement(sql)
ResultSet result = null;
result = ps.executeQuery();
DefaultCategoryDataset hbDataset = new DefaultCategoryDataset();
int i=0;
while (result.next()) {
hbDataset.addValue(i, result.getInt(1), result.getString(2));
i++;
}
result.close();
ps.close();
conn.close();
return hbDataset;
}
catch (SQLException se) {
throw new RuntimeException(se);
}
}
/**
*
* Returns a unique ID for this DatasetProducer
*/
public String getProducerId() {
return "PageViewSecteurData DatasetProducer";
}
/**
* Checks whether curent chart image has expired.
*
* @param params Parameters passed in Request
* @param since Date used for determining expiration
* @return Boolean indicating if Dataset has expired
*/
public boolean hasExpired(Map params, java.util.Date since) {
return false;
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
hi,
problem occured in the database connection for the context.xml file
This is the java file for the connection.
1. DBDataProvider.java
package uk.co.vsj.graph1;
import de.laures.cewolf.DatasetPr oduceExcep tion;
import de.laures.cewolf.DatasetPr oducer;
import java.io.Serializable;
import java.sql.Connection;
import java.sql.PreparedStatement ;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
import java.util.Map;
import javax.naming.Context;
import javax.naming.InitialContex t;
import javax.naming.NamingExcepti on;
import javax.sql.DataSource;
import javax.sql.DataSource;
import org.jfree.data.general.Def aultPieDat aset;
//import sun.jdbc.odbc.ee.DataSourc e;
public class DBDataProvider implements DatasetProducer,Serializab le {
private DataSource dbsrc = null;
public void setDatasource(DataSource indb) {
dbsrc = indb;
}
public Object produceDataset(Map arg0)throws DatasetProduceException {
DefaultPieDataset dataset =new DefaultPieDataset();
Connection conn = null;
PreparedStatement salesquery = null;
System.out.println("After Prepare Statement=====>");
ResultSet res = null;
try {
conn = dbsrc.getConnection();
salesquery = conn.prepareStatement("sel ect location, sum(copies) as sold from sales group by location order by location");
res = salesquery.executeQuery();
while(res.next()) {
// JDBC columns starts at 1
String location =res.getString(1);
double sold = res.getDouble(2);
dataset.setValue(location, sold);
}
} catch (SQLException e) {
e.printStackTrace();
}
return dataset;
}
public boolean hasExpired(Map arg0, Date arg1) {
throw new UnsupportedOperationExcept ion("Not supported yet.");
}
public String getProducerId() {
throw new UnsupportedOperationExcept ion("Not supported yet.");
}
public void DBDataProvider() {
}
}
2.This is also jsp page
graphdb.jsp
<%@ page language="java"contentType ="text/htm l;charset= ISO-8859-1 "pageEncod ing="ISO-8 859-1"%>
<%@taglib uri='/WEB-INF/cewolf.tld'p refix='cew olf' %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sql"uri="http://java.sun.com/jsp/jstl/sql" %>
<!DOCTYPE html PUBLIC "-//W3C//
DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=ISO-8859-1">
<title>
VSJ Database Sourced Data Sample
</title>
<sql:setDataSource
dataSource="jdbc/vsjdb" var="vsjdb" />
</head>
<body>
<jsp:useBean id="dbdata" class="uk.co.vsj.graph1.DB DataProvid er" />
<jsp:setProperty name="dbdata"property="dat asource"va lue="${vsj db}" />
<cewolf:chart
id="dbchart"
type="pie"
title="VSJ Database Sourced Data Sample">
<cewolf:data>
<cewolf:producer id="dbdata"/>
</cewolf:data>
</cewolf:chart>
<p/>
<cewolf:img chartid="dbchart"
renderer="cewolf"
width="640" height="480"/>
<p/>
</body>
</html>
problem occured in the database connection.
problem occured in the database connection for the context.xml file
This is the java file for the connection.
1. DBDataProvider.java
package uk.co.vsj.graph1;
import de.laures.cewolf.DatasetPr
import de.laures.cewolf.DatasetPr
import java.io.Serializable;
import java.sql.Connection;
import java.sql.PreparedStatement
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
import java.util.Map;
import javax.naming.Context;
import javax.naming.InitialContex
import javax.naming.NamingExcepti
import javax.sql.DataSource;
import javax.sql.DataSource;
import org.jfree.data.general.Def
//import sun.jdbc.odbc.ee.DataSourc
public class DBDataProvider implements DatasetProducer,Serializab
private DataSource dbsrc = null;
public void setDatasource(DataSource indb) {
dbsrc = indb;
}
public Object produceDataset(Map arg0)throws DatasetProduceException {
DefaultPieDataset dataset =new DefaultPieDataset();
Connection conn = null;
PreparedStatement salesquery = null;
System.out.println("After Prepare Statement=====>");
ResultSet res = null;
try {
conn = dbsrc.getConnection();
salesquery = conn.prepareStatement("sel
res = salesquery.executeQuery();
while(res.next()) {
// JDBC columns starts at 1
String location =res.getString(1);
double sold = res.getDouble(2);
dataset.setValue(location,
}
} catch (SQLException e) {
e.printStackTrace();
}
return dataset;
}
public boolean hasExpired(Map arg0, Date arg1) {
throw new UnsupportedOperationExcept
}
public String getProducerId() {
throw new UnsupportedOperationExcept
}
public void DBDataProvider() {
}
}
2.This is also jsp page
graphdb.jsp
<%@ page language="java"contentType
<%@taglib uri='/WEB-INF/cewolf.tld'p
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sql"uri="http://java.sun.com/jsp/jstl/sql" %>
<!DOCTYPE html PUBLIC "-//W3C//
DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=ISO-8859-1">
<title>
VSJ Database Sourced Data Sample
</title>
<sql:setDataSource
dataSource="jdbc/vsjdb" var="vsjdb" />
</head>
<body>
<jsp:useBean id="dbdata" class="uk.co.vsj.graph1.DB
<jsp:setProperty name="dbdata"property="dat
<cewolf:chart
id="dbchart"
type="pie"
title="VSJ Database Sourced Data Sample">
<cewolf:data>
<cewolf:producer id="dbdata"/>
</cewolf:data>
</cewolf:chart>
<p/>
<cewolf:img chartid="dbchart"
renderer="cewolf"
width="640" height="480"/>
<p/>
</body>
</html>
problem occured in the database connection.
void addValue(double value, java.lang.Comparable rowKey, java.lang.Comparable columnKey)
void addValue(java.lang.Number value, java.lang.Comparable rowKey, java.lang.Comparable columnKey)
are the only avilable methods in the class org.jfree.data.category.De
I think you need to make the required changes to the types.
Thank You.