Package net.sf.jasperreports.engine

Examples of net.sf.jasperreports.engine.JRResultSetDataSource


    {
      try
      {
        resultSet = statement.executeQuery();
       
        dataSource = new JRResultSetDataSource(resultSet);
      }
      catch (SQLException e)
      {
        throw new JRException("Error executing SQL statement for : " + dataset.getName(), e);
      }
View Full Code Here


       if(rs instanceof List)  { 
         JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource((List) rs);
         jasperPrint = JasperFillManager.fillReport(jasperReport, parametters,ds);
                                }
if(rs instanceof ResultSet) {
       JRResultSetDataSource ds=new  JRResultSetDataSource((ResultSet)rs);
           jasperPrint = JasperFillManager.fillReport(jasperReport, parametters,ds);
                              }
            System.out.println(" taille jasper "+jasperPrint.toString());
            if(jasperPrint != null){
View Full Code Here

    if (dsCandidate instanceof Collection)
      return new JRBeanCollectionDataSource((Collection) dsCandidate);

    if (dsCandidate instanceof ResultSet)
      return new JRResultSetDataSource((ResultSet) dsCandidate);

    if (dsCandidate.getClass().isArray())
      return new JRBeanArrayDataSource((Object[]) dsCandidate);

View Full Code Here

    if (dsCandidate instanceof Collection)
      return new JRBeanCollectionDataSource((Collection) dsCandidate);

    if (dsCandidate instanceof ResultSet)
      return new JRResultSetDataSource((ResultSet) dsCandidate);

    if (dsCandidate.getClass().isArray())
      return new JRBeanArrayDataSource((Object[]) dsCandidate);

View Full Code Here

    JRDataSource ds = new JRBeanCollectionDataSource(collection);
    return generateJasperPrint(dr, layoutManager, ds, new HashMap());
  }

  public static JasperPrint generateJasperPrint(DynamicReport dr, LayoutManager layoutManager, ResultSet resultSet) throws JRException {
    JRDataSource ds = new JRResultSetDataSource(resultSet);
    return generateJasperPrint(dr, layoutManager, ds, new HashMap());
  }
View Full Code Here

  public static void runReportToPDF(String moduleId, HashMap<String, Object> parameterValues, String sql, PreparedStatement preparedstatement, String filename)
  {
    ResultSet resultset;
    Statement statement;
    JRResultSetDataSource jasperresultset;
    JasperPrint jasperPrint = new JasperPrint();
    Connection connection;
    String reportFilename = "";

    init();

    mod.setModuleId(moduleId);

    if (mod.getModuleProperties() == true)
    {

      reportFilename = Common.report_path + JUtility.removeExtensionFromFilename(mod.getReportFilename(), ".jrxml") + ".jasper";

      if (parameterValues == null)
      {
        parameterValues = new HashMap<String, Object>();
      }
      parameterValues.putAll(stdparams);

      try
      {

        connection = Common.hostList.getHost(Common.selectedHostID).getConnection(Common.sessionID);

        sql = JUtility.replaceNullStringwithBlank(sql);

        if (sql.isEmpty())
        {
          if (preparedstatement == null)
          {
            parameterValues.put(JRParameter.REPORT_CONNECTION, connection);
            jasperPrint = JasperFillManager.fillReport(reportFilename, parameterValues, connection);
          } else
          {
            resultset = preparedstatement.executeQuery();
            jasperresultset = new JRResultSetDataSource(resultset);
            parameterValues.put(JRParameter.REPORT_DATA_SOURCE, jasperresultset);
            parameterValues.put(JRParameter.REPORT_CONNECTION, connection);
            jasperPrint = JasperFillManager.fillReport(reportFilename, parameterValues, jasperresultset);
          }
        } else
        {
          statement = Common.hostList.getHost(Common.selectedHostID).getConnection(Common.sessionID).createStatement();
          statement.setFetchSize(1);
          resultset = statement.executeQuery(sql);
          jasperresultset = new JRResultSetDataSource(resultset);
          parameterValues.put(JRParameter.REPORT_DATA_SOURCE, jasperresultset);
          parameterValues.put(JRParameter.REPORT_CONNECTION, connection);
          jasperPrint = JasperFillManager.fillReport(reportFilename, parameterValues, jasperresultset);
        }
View Full Code Here

  public static void runReport(String moduleId, HashMap<String, Object> parameterValues, String sql, PreparedStatement preparedstatement, String printQueue)
  {
    ResultSet resultset;
    Statement statement;
    JRResultSetDataSource jasperresultset;
    JasperPrint jasperPrint = new JasperPrint();
    Connection connection;
    JInternalFrameReportViewer reportviewer;
    Icon reportIcon;
    JRPrintServiceExporter exporter;
    // PrintServiceAttributeSet serviceAttributeSet;
    String reportFilename = "";

    mod.setModuleId(moduleId);

    if (mod.getModuleProperties() == true)
    {
      reportFilename = Common.report_path + JUtility.removeExtensionFromFilename(mod.getReportFilename(), ".jrxml") + ".jasper";

      if (parameterValues == null)
      {
        parameterValues = new HashMap<String, Object>();
      }
      parameterValues.putAll(stdparams);

      printQueue = JUtility.replaceNullStringwithBlank(printQueue);

      if (printQueue.equals(""))
      {
        printQueue = JPrint.getDefaultPrinterQueueName();
      } else
      {
        if (JPrint.getDefaultPrinterQueueName().equals(printQueue) == false)
        {
          JPrint.setPreferredPrinterQueueName(printQueue);
        }
      }

      try
      {

        connection = Common.hostList.getHost(Common.selectedHostID).getConnection(Common.sessionID);

        sql = JUtility.replaceNullStringwithBlank(sql);

        if (sql.isEmpty())
        {
          if (preparedstatement == null)
          {
            parameterValues.put(JRParameter.REPORT_CONNECTION, connection);
            jasperPrint = JasperFillManager.fillReport(reportFilename, parameterValues, connection);
          } else
          {
            resultset = preparedstatement.executeQuery();
            jasperresultset = new JRResultSetDataSource(resultset);
            parameterValues.put(JRParameter.REPORT_DATA_SOURCE, jasperresultset);
            parameterValues.put(JRParameter.REPORT_CONNECTION, connection);
            jasperPrint = JasperFillManager.fillReport(reportFilename, parameterValues, jasperresultset);
          }
        } else
        {
          statement = Common.hostList.getHost(Common.selectedHostID).getConnection(Common.sessionID).createStatement();
          statement.setFetchSize(1);
          resultset = statement.executeQuery(sql);
          jasperresultset = new JRResultSetDataSource(resultset);
          parameterValues.put(JRParameter.REPORT_DATA_SOURCE, jasperresultset);
          parameterValues.put(JRParameter.REPORT_CONNECTION, connection);
          jasperPrint = JasperFillManager.fillReport(reportFilename, parameterValues, jasperresultset);
        }
View Full Code Here

  public static void runReportToPDF(String moduleId, HashMap<String, Object> parameterValues, String sql, PreparedStatement preparedstatement, String filename)
  {
    ResultSet resultset;
    Statement statement;
    JRResultSetDataSource jasperresultset;
    JasperPrint jasperPrint = new JasperPrint();
    Connection connection;
    String reportFilename = "";

    init();

    mod.setModuleId(moduleId);

    if (mod.getModuleProperties() == true)
    {

      reportFilename = Common.report_path  + JUtility.removeExtensionFromFilename(mod.getReportFilename(), ".jrxml") + ".jasper";
     
      if (parameterValues == null)
      {
        parameterValues = new HashMap<String, Object>();
      }
      parameterValues.putAll(stdparams);

      try
      {

        connection = Common.hostList.getHost(Common.selectedHostID).getConnection(Common.sessionID);
       
        sql = JUtility.replaceNullStringwithBlank(sql);

        if (sql.isEmpty())
        {
          if (preparedstatement == null)
          {
            parameterValues.put(JRParameter.REPORT_CONNECTION, connection);
            jasperPrint = JasperFillManager.fillReport(reportFilename, parameterValues, connection);
          }
          else
          {
            resultset = preparedstatement.executeQuery();
            jasperresultset = new JRResultSetDataSource(resultset);
            parameterValues.put(JRParameter.REPORT_DATA_SOURCE, jasperresultset);
            parameterValues.put(JRParameter.REPORT_CONNECTION, connection);
            jasperPrint = JasperFillManager.fillReport(reportFilename, parameterValues, jasperresultset);
          }
        }
        else
        {
          statement = Common.hostList.getHost(Common.selectedHostID).getConnection(Common.sessionID).createStatement();
          statement.setFetchSize(1);
          resultset = statement.executeQuery(sql);
          jasperresultset = new JRResultSetDataSource(resultset);
          parameterValues.put(JRParameter.REPORT_DATA_SOURCE, jasperresultset);
          parameterValues.put(JRParameter.REPORT_CONNECTION, connection);
          jasperPrint = JasperFillManager.fillReport(reportFilename, parameterValues, jasperresultset);
        }
View Full Code Here

  public static void runReport(String moduleId, HashMap<String, Object> parameterValues, String sql,PreparedStatement preparedstatement, String printQueue)
  {
    ResultSet resultset;
    Statement statement;
    JRResultSetDataSource jasperresultset;
    JasperPrint jasperPrint = new JasperPrint();
    Connection connection;
    JInternalFrameReportViewer reportviewer;
    Icon reportIcon;
    JRPrintServiceExporter exporter;
    PrintServiceAttributeSet serviceAttributeSet;
    String reportFilename = "";
   
    mod.setModuleId(moduleId);

    if (mod.getModuleProperties() == true)
    {
      reportFilename = Common.report_path  + JUtility.removeExtensionFromFilename(mod.getReportFilename(), ".jrxml") + ".jasper";
     
      if (parameterValues==null)
      {
        parameterValues = new HashMap<String, Object>();
      }
      parameterValues.putAll(stdparams);

      printQueue = JUtility.replaceNullStringwithBlank(printQueue);
     
      if (printQueue.equals(""))
      {
        printQueue = JPrint.getDefaultPrinterQueueName();
      }
      else
      {
        if (JPrint.getDefaultPrinterQueueName().equals(printQueue) == false)
        {
          JPrint.setPreferredPrinterQueueName(printQueue);
        }
      }

      try
      {
        //jasperReport = (JasperReport) JRLoader.loadObjectFromLocation(Common.report_path + JUtility.removeExtensionFromFilename(mod.getReportFilename(), ".jrxml")+ ".jasper");
        //jasperReport = (JasperReport) RepositoryUtil.getReport(Common.report_path + JUtility.removeExtensionFromFilename(mod.getReportFilename(), ".jrxml")+ ".jasper");
        connection = Common.hostList.getHost(Common.selectedHostID).getConnection(Common.sessionID);

        sql = JUtility.replaceNullStringwithBlank(sql);

        if (sql.isEmpty())
        {
          if (preparedstatement==null)
          {
            parameterValues.put(JRParameter.REPORT_CONNECTION, connection);
            jasperPrint = JasperFillManager.fillReport(reportFilename, parameterValues, connection);
          }
          else
          {
            resultset = preparedstatement.executeQuery();
            jasperresultset = new JRResultSetDataSource(resultset);
            parameterValues.put(JRParameter.REPORT_DATA_SOURCE, jasperresultset);
            parameterValues.put(JRParameter.REPORT_CONNECTION, connection);
            jasperPrint = JasperFillManager.fillReport(reportFilename, parameterValues, jasperresultset);
          }
        }
        else
        {
          statement = Common.hostList.getHost(Common.selectedHostID).getConnection(Common.sessionID).createStatement();
          statement.setFetchSize(1);
          resultset = statement.executeQuery(sql);
          jasperresultset = new JRResultSetDataSource(resultset);
          parameterValues.put(JRParameter.REPORT_DATA_SOURCE, jasperresultset);
          parameterValues.put(JRParameter.REPORT_CONNECTION, connection);
          jasperPrint = JasperFillManager.fillReport(reportFilename, parameterValues, jasperresultset);
        }
View Full Code Here

    JRDataSource ds = new JRBeanCollectionDataSource(collection);
    return generateJasperPrint(dr, layoutManager, ds, new HashMap());
  }

  public static JasperPrint generateJasperPrint(DynamicReport dr, LayoutManager layoutManager, ResultSet resultSet) throws JRException {
    JRDataSource ds = new JRResultSetDataSource(resultSet);
    return generateJasperPrint(dr, layoutManager, ds, new HashMap());
  }
View Full Code Here

TOP

Related Classes of net.sf.jasperreports.engine.JRResultSetDataSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.