>> Why does the JDBC API allow this behaviour?
Both the CallableStatement and PreparedStatements are still implementations of the Statement interface, and hence must implement the methods declared in Statement. Now, I would expect an exception to be thrown when you try to execute the ps.executeQuery(<query
string>
method on an instance of PreparedStatement. My question is which exception did you receive? I have not decompiled the PreparedStatement class to see if Sun decided to allow Driver providers to determine the exception that should be thrown when this method is executed, or whether they decided to throw a NotImplementedException. Still, getting an exception is what I would have expected.
>> Is there ever a reason why you'd do such a thing?
Yes, as stated above the PreparedStatement must provide an implementation of all methods in the Statement interface. The logical result of executing the method would be an exception.
>> Is it a fair statement that some of the Statement methods should never be called on a PreparedStatement (and CallableStatement) instance?
Yes, I think this is a fair and correct statement. While the method must be present due to implementing the Statement interface, calling executeQuery(String query) method of an instance of PreparedStatement is not valid.
Mike