fillreport java methods error while compiling

0


hi im trying to develop a crime system using netbeans and in my servlet i use jasper fill report method but when i compile i get the error error: no suitable method found for fillReport(String,Map<String,String>,Connection)
        JasperPrint jasperPrint = JasperFillManager.fillReport( path , parameterMap, connection );
                                                   ^
    method JasperFillManager.fillReport(String,Map<String,Object>,Connection) is not applicable
      (argument mismatch; Map<String,String> cannot be converted to Map<String,Object>)



C:\Users\NICK\Documents\NetBeansProjects\New folder\crime-reporting-system\src\java\reports\CrimeAtPlaceHTMLReportServlet.java:43: error: no suitable method found for fillReport(String,Map<String,String>,Connection)
        JasperPrint jasperPrint = JasperFillManager.fillReport( path , parameterMap, connection );
                                                   ^
    method JasperFillManager.fillReport(String,Map<String,Object>,Connection) is not applicable
      (argument mismatch; Map<String,String> cannot be converted to Map<String,Object>)
    method JasperFillManager.fillReport(InputStream,Map<String,Object>,Connection) is not applicable
      (argument mismatch; String cannot be converted to InputStream)
    method JasperFillManager.fillReport(JasperReport,Map<String,Object>,Connection) is not applicable
      (argument mismatch; String cannot be converted to JasperReport)
    method JasperFillManager.fillReport(String,Map<String,Object>,JRDataSource) is not applicable
      (argument mismatch; Map<String,String> cannot be converted to Map<String,Object>)
    method JasperFillManager.fillReport(InputStream,Map<String,Object>,JRDataSource) is not applicable
      (argument mismatch; String cannot be converted to InputStream)
    method JasperFillManager.fillReport(JasperReport,Map<String,Object>,JRDataSource) is not applicable
      (argument mismatch; String cannot be converted to JasperReport)
C:\Users\PETA\Documents\NetBeansProjects\New folder\crime-reporting-system\src\java\reports\CrimeAtPlaceXLReportServlet.java:44: error: no suitable method found for fillReport(String,Map<String,String>,Connection)
        JasperPrint jasperPrint = JasperFillManager.fillReport( path , parameterMap, connection );
                                                   ^
    method JasperFillManager.fillReport(String,Map<String,Object>,Connection) is not applicable
      (argument mismatch; Map<String,String> cannot be converted to Map<String,Object>)
    method JasperFillManager.fillReport(InputStream,Map<String,Object>,Connection) is not applicable
      (argument mismatch; String cannot be converted to InputStream)
    method JasperFillManager.fillReport(JasperReport,Map<String,Object>,Connection) is not applicable
      (argument mismatch; String cannot be converted to JasperReport)
    method JasperFillManager.fillReport(String,Map<String,Object>,JRDataSource) is not applicable
      (argument mismatch; Map<String,String> cannot be converted to Map<String,Object>)
    method JasperFillManager.fillReport(InputStream,Map<String,Object>,JRDataSource) is not applicable
      (argument mismatch; String cannot be converted to InputStream)
    method JasperFillManager.fillReport(JasperReport,Map<String,Object>,JRDataSource) is not applicable
      (argument mismatch; String cannot be converted to JasperReport)
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
2 errors
4 warnings
C:\Users\NICK\Documents\NetBeansProjects\New folder\crime-reporting-system\nbproject\build-impl.xml:874: The following error occurred while executing this line:
C:\Users\NICK\Documents\NetBeansProjects\New folder\crime-reporting-system\nbproject\build-impl.xml:333: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 2 seconds)

      kindly help me troubleshoot and incase i use deprecated methods what is the alternative way to go about it
      
      
      
      
      here is my servlet source code;
      
      
      
CrimeAtPlaceHTMLReportServlet      
            
package reports;

import java.sql.*;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import net.sf.jasperreports.engine.*;
import net.sf.jasperreports.engine.export.*;
import net.sf.jasperreports.engine.util.JRLoader;

public class CrimeAtPlaceHTMLReportServlet extends HttpServlet
{
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException
    {
      Connection connection;
      ServletOutputStream servletOutputStream = response.getOutputStream();
      InputStream reportStream = getServletConfig().getServletContext().getResourceAsStream( "/reports/crimeAtPlace.jasper" );
      //HashMap parameterMap = new HashMap();
      
      JRExporter exporter = null;
      Map<String, String> parameterMap = new HashMap<String, String>();
            
      String place = ( String )getServletConfig().getServletContext().getAttribute( "place" );
      System.out.println( "Value recieved = " + place );
      
      parameterMap.put( "crime_place", place );
      System.out.println( "Value in Map = " + parameterMap.get( "crime_place" ) );
      
      try
      {
        Class.forName( "com.ibm.db2.jcc.DB2Driver" );
        connection = DriverManager.getConnection ( "jdbc:db2:CRIMEDB" );
        String path = ( String )getServletConfig().getServletContext().getRealPath( "/" );
        path = path + "reports\\" + "crimeAtPlace2.jasper";
        
        JasperPrint jasperPrint = JasperFillManager.fillReport( path , parameterMap, connection );
        
        //Original servlet code
        /*response.setContentType( "text/html" );
        String html = JasperRunManager.runReportToHtmlFile( path, parameterMap, connection );
        System.out.println( html );*/
        
        response.setContentType( "text/html" );
        exporter = new JRHtmlExporter();
        exporter.setParameter( JRExporterParameter.JASPER_PRINT, jasperPrint );
        exporter.setParameter( JRExporterParameter.OUTPUT_STREAM, servletOutputStream );
        exporter.setParameter( JRExporterParameter.INPUT_FILE, path );
        //exporter.setParameters( parameterMap );
        System.out.println( "abc" );
        
        exporter.exportReport();
        System.out.println( "def" );
        
        connection.close();
        
        servletOutputStream.flush();
        servletOutputStream.close();
      }
      catch( Exception e )
      {
        // display stack trace in the browser
        StringWriter stringWriter = new StringWriter();
        PrintWriter printWriter = new PrintWriter(stringWriter);
        e.printStackTrace(printWriter);
        response.setContentType("text/plain");
        response.getOutputStream().print(stringWriter.toString());
      }
      parameterMap.remove( "crime_place" );
    }
    
    public void doPost( HttpServletRequest request, HttpServletResponse response )
            throws IOException, ServletException
    {
      doGet( request, response );        
    }
}


      


kindly help me troubleshoot and incase i use deprecated methods wht is the alternative way to go about it  This is my final year project email;nickmart100@gmail.com
    

nickmart100's picture
Joined: Nov 20 2016 - 4:31am
Last seen: 3 years 8 months ago

2 Answers:

0

Try

Map<String, String> parameterMap = new HashMap<String, Object>();

hozawa's picture
64188
Joined: Apr 24 2010 - 4:31pm
Last seen: 1 year 1 month ago
0

thanks hozawa im currenly a beginner could you post or send me the alternative source code for the above servlet with your new method implemented ill appreciate

nickmart100's picture
Joined: Nov 20 2016 - 4:31am
Last seen: 3 years 8 months ago
Feedback
randomness