0

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"), "");
                    }
MonkeyBonkey
  • 46,433
  • 78
  • 254
  • 460
  • In your second code snippet where you use `NamedParameterJdbcTemplate` it looks like you're looking for a column called `views` but there is nothing called that in your `SELECT` statement. Maybe amend that and try it again. – mohammedkhan Mar 13 '20 at 16:09
  • it errors before that - looking at the docs it looks like druid doesn't support prepared statements – MonkeyBonkey Mar 18 '20 at 12:27

1 Answers1

0

Looking through the bugs list - Druid doesn't support prepared statements.

MonkeyBonkey
  • 46,433
  • 78
  • 254
  • 460