PreparedStatement.execute() "Returns true if the first result is a ResultSet object; false if the first result is an update count or there is no result" (quote from JavaDoc).
Mockrunner expects that queries (select) return a ResultSet and inserts/updates return an update count.
You can specify that any SQL you like returns a ResultSet with AbstractResultSetHandler.prepareReturnsResultSet(...). Then you'll get true for the execute call.
Kind regards,
Alwin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi
I'm using MockRunner to test some DB code and I'm very pleased with the way it works.
But I have a problem when I try to test an INSERT INTO statement.
PreparedStatement statement = null;
...
statement = getPreparedStatement(TUL0060.getInsertIntoSql());
...
return statement.execute();
My code expect a true boolean result from the 'statement.execute()' but I always get a false.
I can't seem to find any examples on how to set this up?
Best regards
Thomas
PreparedStatement.execute() "Returns true if the first result is a ResultSet object; false if the first result is an update count or there is no result" (quote from JavaDoc).
Mockrunner expects that queries (select) return a ResultSet and inserts/updates return an update count.
You can specify that any SQL you like returns a ResultSet with AbstractResultSetHandler.prepareReturnsResultSet(...). Then you'll get true for the execute call.
Kind regards,
Alwin
Thanks
Couldn't get it to work yesterday - but it works today! ;o)
// Thomas
prepareReturnsResultSet("UPDATE MUREXDB.MKV_SYB SET MUREX_STATUS = ? WHERE MKV_ID = ?",false);
statement =connection.prepareStatement("UPDATE MUREXDB.MKV_SYB SET MUREX_STATUS = ? WHERE MKV_ID = ?");
statement.setInt(1,3);
statement.setInt(2,12);
boolean flag=statement.execute();
System.out.println("Flag "+flag);
Still flag is false