#21 executequery returns null, violating the jdbc api


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:
a ResultSet object that contains the data produced by the query; never null"



  • Alwin Ibba

    Alwin Ibba - 2007-01-12

    Logged In: YES
    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.

  • Alwin Ibba

    Alwin Ibba - 2007-01-17
    • assigned_to: nobody --> aibba
    • status: open --> closed

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks