Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Problem in dataset when linking with mssqlser

Help
chinna
2009-06-26
2013-01-13
  • chinna
    chinna
    2009-06-26

    Hi
    I am using cewolf tag libraries in jsps to producing charts. I am using mssql server 2000 to retrieve data dynamically but my server reporting error when retrieving and producing dataset exception
    package com.cewolf;
    import java.io.Serializable;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.util.Date;
    import java.util.Map;
    import java.util.*;

    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    import org.jfree.data.category.CategoryDataset;
    import org.jfree.data.category.DefaultCategoryDataset;

    import com.sellspace.util.DatabaseConnection;

    import de.laures.cewolf.DatasetProduceException;
    import de.laures.cewolf.DatasetProducer;
    import de.laures.cewolf.links.CategoryItemLinkGenerator;
    import de.laures.cewolf.tooltips.CategoryToolTipGenerator;
    public class piechart implements DatasetProducer, CategoryToolTipGenerator, CategoryItemLinkGenerator, Serializable {

      
        private static final Log log = LogFactory.getLog(piechart.class);
        public Object produceDataset(Map params) throws DatasetProduceException {
            log.debug("producing data.");
            DefaultCategoryDataset ds = new DefaultCategoryDataset(){
                protected void finalize() throws Throwable {
                    super.finalize();
                    log.debug(this +" finalized.");
                }
            };
            try {
               
                 java.sql.Connection con=DatabaseConnection.getConnection();
                 Statement st=con.createStatement();
                 ResultSet rs=st.executeQuery("select country,siteid from siteownerdetails ORDER BY siteid");
               
               
                
                 while (rs.next()) {
                    ds.addValue(rs.getString(1),rs.getInt(2));
                   
                   
                     rs.close();
                 }
                 } catch (SQLException se) {
                      throw new RuntimeException(se);
                }
                 return ds;
            }
        public boolean hasExpired(Map params, Date since) {       
            log.debug(getClass().getName() + "hasExpired()");
            return (System.currentTimeMillis() - since.getTime())  > 5000;
        }
        public String getProducerId() {
            return "PageViewCountData DatasetProducer";
        }
        //public String generateLink(Object data, int series, Object category) {
           // return seriesNames[series];
      //  }
        protected void finalize() throws Throwable {
            super.finalize();
            log.debug(this + " finalized.");
        }
       /* public String generateToolTip(CategoryDataset arg0, int series, int arg2) {
            return seriesNames[series];
        }*/
        public String generateToolTip(CategoryDataset arg0, int arg1, int arg2) {
            // TODO Auto-generated method stub
            return null;
        }
        public String generateLink(Object arg0, int arg1, Object arg2) {
            // TODO Auto-generated method stub
            return null;
        }

    }

    This is my java file please suggest me how to retrieve data correctly.
    Thanx in advance