I was having the same error from JDBC. Checked everything and my query was fine. Turned out, in where clause I have an argument:
where s.some_column = ?
And the value of the argument I was passing in was null. This also gives the same error which is misleading because when you search the internet you end up that something is wrong with the query structure but it's not in my case. Just thought someone may face the same issue