I'm trying to use the Calcite Avatica JDBC driver calling into a sample Druid database using a Spring Boot project. Following along most examples I fashioned this query and it throws an exception if I pass along new Object[] { cityName }
. However, if I pass along Object[] {}
I don't get that same exception.
String cityName = "Aachen";
results = jdbcTemplate.query("SELECT cityName, countryName FROM wikipedia WHERE cityName = ?",
new Object[] { cityName },
(rs, rowNum) -> {
return new City(cityName, rs.getString("countryName"));
}
);
Here's the exception
org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL [SELECT cityName, countryName FROM wikipedia WHERE cityName = ?]; SQL state [00000]; error code [-1]; Error -1 (00000) : while preparing SQL: SELECT cityName, countryName FROM wikipedia WHERE cityName = ?; nested exception is org.apache.calcite.avatica.AvaticaSqlException: Error -1 (00000) : while preparing SQL: SELECT cityName, countryName FROM wikipedia WHERE cityName = ?
I even get the same exception if I switch to NamedParameterJdbcTemplate
namedParameterJdbcTemplate.query("SELECT cityName, countryName, comment FROM wikipedia WHERE cityName = :cityName",
new MapSqlParameterSource()
.addValue("cityName", "Aachen"),
(rs, rowNum) -> {
return new SponsoredPostStats(sponsoredPostId, rs.getInt("views"), "");
}