Back Forum Reply New

Spring JDBC

mons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:91)
at org..jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:623)
at org..jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:566)
... 10 more
but when i execute the query whithout the parameters, the query result is correct.

Can you explain me why my query generate this error ?


Code:
String query = quot;SELECT CASE WHEN max(?)+1 lt; 0 OR count(*) = 0 THEN 1 ELSE max(?) + 1 END FROM ?quot;;
return jdbcTemplate.queryForInt(query, new Object[] { column.getColumnName(), column.getColumnName(), column.getTable().getName()});
}
are you trying to replace names of the columns with ? placeholders in max(?)??!

Placeholders in JDBC are only supported in the where or set clause no where else, so not sure what this has to do with spring.

ok i see, in the documentation this information is not present
cf
intqueryForInt(String sql, Object[] args)
Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, resulting in an int value.
And why should that be in the documenation? It is JDBC it is in the JDBC specification, should the spring documentation include all the documentation of the APIs/frameworks it uses?

No it's not the goal

i have downloaded the spring source code it's the better documentation than i can get
¥
Back Forum Reply New