2

My task is to get multiple resultsets from a stored procedure & return as json object along with model number, but unfortunately i'm getting only first resultset

to get multiple resultset i'm trying to do something like

        boolean isResultExists = false;
        isResultExists = callableStatement.execute();

        resultSet = callableStatement.getResultSet();
        resultSetMetaData = resultSet.getMetaData();
        while (resultSet.next()) {
            mapObject = new LinkedHashMap<String, Object>();

            for (int i = 1; i <= resultSetMetaData.getColumnCount(); i++)
                mapObject.put(resultSetMetaData.getColumnLabel(i),
                        resultSet.getObject(i));

            listOfProperties.add(mapObject);
            // isResultExists = callableStatement.getMoreResults();
        }

this code is returning only 1st resultset & if i try to use

isResultExists = callableStatement.getMoreResults();

I'm getting

java.sql.SQLException: Operation not allowed after ResultSet closed" Exception

Can anybody suggest best way to get multiple resultset & convert to json Objects

Thanks in advance

SatyaTNV
  • 4,137
  • 3
  • 15
  • 31

0 Answers0