I have a report desing in BIRT. When i execute it with run-option in designer everything works properly. But when i try to execute it in code it throws SQL syntax error. Birt version is 4.14
As i see, there is no connection with real sql problem. Here are some logs a have:
Apr 23, 2024 6:36:39 PM org.eclipse.birt.data.engine.odaconsumer.Connection prepareOdaQuery
SEVERE: Failed to prepare the following query for the data set type (org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet).
[SELECT public.users.first_name, public.users.last_name
FROM public.users
WHERE id = ?
]
org.eclipse.birt.report.data.oda.jdbc.JDBCException: Error preparing SQL statement.
SQL error #1:Syntax error: Encountered "public" at line 1, column 8
Then i tried to remove ‘public’, still an error:
PM org.eclipse.birt.data.engine.odaconsumer.Connection prepareOdaQuery
SEVERE: Failed to prepare the following query for the data set type (org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet).
[SELECT first_name, last_name
FROM users
WHERE id = ?
]
org.eclipse.birt.report.data.oda.jdbc.JDBCException: Error preparing SQL statement.
SQL error #1:Schema 'SA' does not exist
Thought that the problem might be in a param. Tried to remove it
Apr 23, 2024 6:40:02 PM org.eclipse.birt.data.engine.odaconsumer.Connection prepareOdaQuery
SEVERE: Failed to prepare the following query for the data set type (org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet).
[SELECT first_name, last_name
FROM users
]
org.eclipse.birt.report.data.oda.jdbc.JDBCException: Error preparing SQL statement.
SQL error #1:Schema 'SA' does not exist
This is how i form a report in code:
public void generateReport(Integer userId, Integer courseId, HttpServletResponse response, HttpServletRequest request) throws EngineException, IOException, SQLException {
IReportRunnable reportDesign = reportEngine.openReportDesign("UserStatistics\user_answers_statistic_for_course.rptdesign"); // classpath in the result jar
IRunAndRenderTask task = reportEngine.createRunAndRenderTask(reportDesign);
response.setContentType(reportEngine.getMIMEType("pdf"));
PDFRenderOption pdfRenderOption = new PDFRenderOption();
pdfRenderOption.setOutputFormat(HTMLRenderOption.OUTPUT_FORMAT_PDF);
task.setRenderOption(pdfRenderOption);
pdfRenderOption.setOutputStream(response.getOutputStream());
task.getAppContext().put("OdaJDBCDriverPassInConnection", dataSource.getConnection());
task.setParameter("UserId", userId, "");
task.setParameter("CourseId", courseId, "");
task.run();
}
Арина Бабаян is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.