executequery returns null, violating the jdbc api
Brought to you by:
aibba
When using the mock JDBC classes, if the method executeQuery is run using an SQL statement for which there is no resultset defined, null is returned. This is contrary to the API for jdbc. For the preparedstatement class, the executequery method cannot return null. An exception should be thrown instead.
According to the API:
"Returns:
a ResultSet object that contains the data produced by the query; never null"
Email:
michael.jordan@unico.com.au
Logged In: YES
user_id=804648
Originator: NO
I don't consider this a bug. Mockrunner JDBC was never meant to support the JDBC spec in all cases. Mockrunner does not interpret any SQL statements and can not know if an SQL statement should return a ResultSet. If you call executeQuery, Mockrunner expects that this statement is a query and tries to find a ResultSet. If it doesn't find one, it expects that you forgot to prepare an action for this statement (a valid ResultSet or an exception) and gives you null. In fact, Mockrunner is very stupid and will do the things you ask for (including SQL exceptions). If you want an exception, you have to prepare this exception for an SQL statement and Mockrunner will throw it. A real JDBC driver talking to a real database does know that an update statement does not return a ResultSet and throws an exception.