right syntax to use near ‘?’

You should execute the PrepareStatement with no parameters as follows:

statement.executeQuery()

Calling executeQuery with a String parameter will execute the provided query as is (without the bound parameters).

Leave a Comment