I tried to execute the following oracle query using JdbcTemplate in Java:
select RESOURCE_ID from REPRO_PRINTING_JOB where (USER_ID=? and PRINTING_CENTER_ID=?) group by RESOURCE_ID union all select RESOURCE_ID from REPRO_PRINTING_JOB_OLD where (USER_ID=? and PRINTING_CENTER_ID=? and STATE='CM') group by RESOURCE_ID
The query works fine in the oracle query browser, but does not work at run time in java. What could be the source of this problem? I heard something about Jdbc not being able to handle case. It's true?
ADDED JAVA CODE (FIXED): I call the request using getStatement (), which retrieves the request from an external source (properties file) in the form:
public List<PrintingJob> getPrintingJobsByCreatedUserId(String createdUserId, String userId) { if(log.isDebugEnabled()) { log.debug("getReportItemsByUserId(" + createdUserId + "," + userId + ")"); } try { System.out.println("getPrintingJobsByResourceId : createdUserId :"+createdUserId+",userId : "+userId); return getJdbcTemplate().query(getStatement("gen.report.userid"), new Object[]{createdUserId, userId, createdUserId, userId}, new PrintingJobMapper()); } catch (DataAccessException ex) { log.error("Error executing query: " + ex.getClass() + ":" + ex.getMessage()); return null; } }
source share