Search code examples
javaspringjdbctemplate

Java Spring JdbcTemplate where Clause not working


I'm struggling writing a simple sql statement using JdbcTemplate. The where clause is simply not working.

private static final String SELECT_CLAUSE =
        "SELECT count(*) " +
        "FROM AUSSCHUETTUNG_AUD " +
        "WHERE rev = 20008907 ";

Integer count = jdbcTemplate.queryForObject( SELECT_CLAUSE, Integer.class );

The result of the count is 0, instead of 1.

Without where clause, the count is 1200.

The column rev has a value of 20008907.

When I do change the where clause as follow "where 1=1", then 1200 is returned.

The DB is Oracle (oracle driver version 8).

Here is the output when running the sql in "Oracle SQL DEVELOPER"

enter image description here


Solution

  • I found the reason why the where clause was not working...... I was connecting to a different DB from within the application. My mistake..... :-(