Obviously,
Select Message From "public".USERS Where ID = '1'
Is a perfectly legal statement.
So is
Select Message From "public".USERS Where ID = '1'
In fact, they're identical. The only difference between the two is that the second is the result of a PreparedStatement that was initially
Select Message From "public".USERS Where ID = ?
And parameterised with the ID value of 1.
In fact, when I attempt to hard code the statement to be executed, things run perfectly fine, and I receive the expected output.
Through testing, I have figured out that the problem is actually that if the parameter is a string initially, there is no problem. So:
PreparedStatement statement = connection.prepareStatement("Select * from table where ID = ?");
statement.setString(1, param);
Will work, if param is declared as
String param = "1";
But not if you declare it in any other way.
For example,
String param = Integer.toString(1);
String param = String.valueOf(1);
String param = ""+1;
Will all cause the error.
I am completely at a loss as to A) What's causing such a peculiar error, and B) Why even if you convert the int to a string that has the exact same value of a string, the one that was originally an int causes an error.