hi guys..........this is the code I'm trying to run
package dbpack;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.*;
import org.jfree.chart.*;
import org.jfree.data.jdbc.*;
import org.jfree.data.general.*;
public class chartdb {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
//private void readData()
//}
private PieDataset readData() {
JDBCPieDataset data = null;
String url = "jdbc:mysql://localhost/jfreechartdb";
Connection con;
try {
Class.forName("com.mysql.jdbc.Driver");
}
catch (ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url, "jfreechart", "password");
data = new JDBCPieDataset(con);
String sql = "SELECT * FROM PIEDATA1;";
data.executeQuery(sql);
con.close();
}
catch (SQLException e) {
System.err.print("SQLException: ");
System.err.println(e.getMessage());
}
catch (Exception e) {
System.err.print("Exception: ");
System.err.println(e.getMessage());
}
return data;
}
}
}
this is code where I want to get data from MySQL & show it on "jfreechart". but I'm getting a error
Syntax error on token(s), misplaced construct(s)
Syntax error, insert ";" to complete BlockStatements
at dbpack.chartdb.main(chartdb.java:20)
on this line
private PieDataset readData() {
the error still exists if I include ";" after readdata()
can you please help me regarding this. I'm lost & confused