version
- JDK:1.8
- SpringBoot:2.2.4.RELEASE
- postgresql driver:42.2.11
- postgresql: 9.4
question
When I use NamedParameterJdbcTemplate# query error
code
String sql="select percentile_cont(0.5) WITHIN GROUP (order by dm_assistant_user_wechat.user_id) as alias_key_1 from dm_assistant_user_wechat offset 0 limit 500";
queryResult = jdbcTemplate.query(sql, Maps.newHashMap(), new ColumnMapRowMapper());
error
PreparedStatementCallback; uncategorized SQLException for SQL [select percentile_cont(0.5) WITHIN GROUP (order by dm_assistant_user_wechat.user_id) as alias_key_1 from dm_assistant_user_wechat offset 0 limit 500]; SQL state [null]; error code [0]; sql injection violation, syntax error: syntax error, error in :'THIN GROUP (order by dm_assistant_u', expect BY, actual LPAREN pos 42, line 1, column 42, token LPAREN : select percentile_cont(0.5) WITHIN GROUP (order by dm_assistant_user_wechat.user_id) as alias_key_1 from dm_assistant_user_wechat offset 0 limit 500; nested exception is java.sql.SQLException: sql injection violation, syntax error: syntax error, error in :'THIN GROUP (order by dm_assistant_u', expect BY, actual LPAREN pos 42, line 1, column 42, token LPAREN : select percentile_cont(0.5) WITHIN GROUP (order by dm_assistant_user_wechat.user_id) as alias_key_1 from dm_assistant_user_wechat offset 0 limit 500
- Asked the PGJDBC developers, confirming not PGJDBC problem, I think it may be springboot NamedParameterJdbcTemplate problem.
pgjdbc issue
Comment From: snicoll
I don't really understand what would be the problem with NamedParameterJdbcTemplate
. The SQL that's sent to the driver is the same as the one that the sample in the pgjdbc issue. If you can provide a small sample similar to the one in the pgjdbc issue that's failing with NamedParameterJdbcTemplate
, we can reopen this issue.