No query executer factory registered for the 'sql' language

0

Hello,

I have the following error When I try to fill my report before generation.

Exception in thread "main" net.sf.jasperreports.engine.JRRuntimeException: No query executer factory registered for the 'sql' language.
        at net.sf.jasperreports.engine.util.JRQueryExecuterUtils.getExecuterFactory(JRQueryExecuterUtils.java:114)
        at net.sf.jasperreports.engine.fill.JRFillDataset.createQueryDatasource(JRFillDataset.java:1083)
        at net.sf.jasperreports.engine.fill.JRFillDataset.initDatasource(JRFillDataset.java:668)
        at net.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBaseFiller.java:1281)
        at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:900)
        at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:845)
        at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:61)
        at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:446)
        at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:849)

 

This error appears when I try to create an executable jar of my project with Eclipse. When I simply run my class using eclipse, without passing through a JAR file, the report is generated with success.

 

Here is my code:

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.text.DateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Map;
 
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.util.JRLoader;
 
public class ReportGenerator {
 
    private DateFormat sqlDateFormat = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 
    Connection conn;
 
    public void generateReport() {
 
        try {
            Class.forName("com.mysql.jdbc.Driver");
            conn = DriverManager.getConnection(
                    "jdbc:mysql://localhost:3306/stats", "user", "pass");
            System.out.println("Loading Report Designs");
            //InputStream input = new FileInputStream(new File(
            //        "jasper/report2.jasper"));
 
            InputStream input = new FileInputStream(new File(
                    "report/reportGC.jasper"));
 
            JasperReport jasperReport = (JasperReport)JRLoader.loadObject(input);
 
            System.out.println("Creating JasperPrint Object");
            //Map<String, String> parameters = new HashMap<String, String>();
            //parameters.put("ReportTitle", "PDF JasperReport");
 
            Map<String, Object> parameters = new HashMap<String, Object>();
 
            // Filling title
            //parameters.put("ReportTitle", "PDF JasperReport");
 
            Calendar cStart = new GregorianCalendar();
            Calendar cEnd = new GregorianCalendar();
 
            cStart.add(Calendar.DAY_OF_MONTH, -7);
 
            // Filling parameters
            parameters.put(("sql_start_date"), sqlDateFormat.format(cStart.getTime()));
            parameters.put(("sql_end_date"), sqlDateFormat.format(cEnd.getTime()));
 
            JasperPrint jasperPrint = JasperFillManager.fillReport(
                    jasperReport, parameters, conn);
 
//            JasperPrint jasperPrint = JasperFillManager.fillReport(
//                    jasperReport, null, conn);
 
            // Exporting the report
            OutputStream output = new FileOutputStream(new File(
                    "report/report2.pdf"));
 
            JasperExportManager.exportReportToPdfStream(jasperPrint, output);
 
            System.out.println("Report Generation Complete");
            conn.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (JRException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
 
    public static void main(String[] args) {
        new ReportGenerator().generateReport();
    }
}

For information, I use Jasper Reports v5.1.2

Can someone help me ?? I'm stuck with this issue... Thank you in advance !

mathieu.kergosien's picture
Joined: Jun 18 2013 - 3:28am
Last seen: 6 years 4 weeks ago

0 Answers:

No answers yet
Feedback