#32 JDBC: Preparing multiple global result sets doesn't work

closed
nobody
None
5
2008-03-11
2008-03-11
henz
No

I've just tried to use the method

statementHandler.prepareGlobalResultSets(resultSets);

but it didn't work as expected, the class under test only received the same (first) result for consecutive sqls.

I checked the implementation and to me it looks like

AbstractResultSetHandler.getGlobalResultSet()

should not always return the first prepared result set but should rather work like a queue.

Here is the method that I used:

private void prepareResultSet(String[][] resultsToBeReturned) {

MockConnection connection = getJDBCMockObjectFactory().getMockConnection();
StatementResultSetHandler statementHandler = connection.getStatementResultSetHandler();
MockResultSet[] resultSets = new MockResultSet[resultsToBeReturned.length];

for(int i=0; i<resultsToBeReturned.length; i++) {
String[] result = resultsToBeReturned[i];
MockResultSet resultSet = statementHandler.createResultSet();
if(result.length>0) resultSet.addRow(result);
resultSets[i] = resultSet;
}
statementHandler.prepareGlobalResultSets(resultSets);
}

Discussion

  • Alwin Ibba

    Alwin Ibba - 2008-03-11
    • status: open --> closed
     
  • Alwin Ibba

    Alwin Ibba - 2008-03-11

    Logged In: YES
    user_id=804648
    Originator: NO

    This is not a bug. prepareGlobalResultSets is not meant to receive different results for consecutive sqls but multiple results for one sql. See Statement.getMoreResults().

     

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

Sign up for the SourceForge newsletter:





No, thanks