Jump to content
We've recently updated our Privacy Statement, available here ×

fillreport java methods error while compiling


nickmart100

Recommended Posts


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:UsersNICKDocumentsNetBeansProjectsNew foldercrime-reporting-systemsrcjavareportsCrimeAtPlaceHTMLReportServlet.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:UsersPETADocumentsNetBeansProjectsNew foldercrime-reporting-systemsrcjavareportsCrimeAtPlaceXLReportServlet.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:UsersNICKDocumentsNetBeansProjectsNew foldercrime-reporting-systemnbprojectbuild-impl.xml:874: The following error occurred while executing this line:
C:UsersNICKDocumentsNetBeansProjectsNew foldercrime-reporting-systemnbprojectbuild-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
    

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...