Skip to content
Advertisement

Use a list of strings in IN clause with JDBI

I’m using JDBI / Dropwizard for a project and would like to run some simple queries. I have a query like so:

private static final String GET_STUFF = "SELECT * FROM myTable WHERE state IN (:desiredState)"

I bind the variable in my method like so:

JavaScript

However, I get the following error when running:

JavaScript

I’m passing in states as an ArrayList of type String, so I’m a bit confused what’s going on here. Does anyone know the correct way to do In with JDBI?

Advertisement

Answer

Use annotation @BindIn instead of @Bind. Also, :desiredState should be written as <desiredState>

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement