Note that there are some explanatory texts on larger screens.

plurals
  1. POJava Spring JDBC template problem
    primarykey
    data
    text
    <pre><code>public List&lt;Weather&gt; getWeather(int cityId, int days) { logger.info("days: " + days); return getSimpleJdbcTemplate().query("SELECT weather.id, cities.name, weather.date, weather.degree " + "FROM weather JOIN cities ON weather.city_id = cities.id " + "WHERE weather.city_id = ? AND weather.date BETWEEN now()::date AND (now() + '? days')::date", this.w_mapper, cityId, days); } </code></pre> <p>error : </p> <pre><code>org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.dao.DataIntegrityViolationException: PreparedStatementCallback; SQL [SELECT weather.id, cities.name, weather.date, weather.degree FROM weather JOIN cities ON weather.city_id = cities.id WHERE weather.city_id = ? AND weather.date BETWEEN now()::date AND (now() + '? days')::date]; The column index is out of range: 2, number of columns: 1.; nested exception is org.postgresql.util.PSQLException: The column index is out of range: 2, number of columns: 1. </code></pre> <p>it works with :</p> <pre><code>public List&lt;Weather&gt; getWeather(int cityId, int days) { logger.info("days: " + days); return getSimpleJdbcTemplate().query("SELECT weather.id, cities.name, weather.date, weather.degree " + "FROM weather JOIN cities ON weather.city_id = cities.id " + "WHERE weather.city_id = ? AND weather.date = now()::date", this.w_mapper, cityId); } </code></pre> <p><strong>so the problem is when im using two ? marks in my query. how can i make it work to with 2 ? marks???</strong></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload