/** * Advance the result set and return a Record populated * with values from the next valid row in the result set. Intended solely * for cursored stream support. */ public AbstractRecord cursorRetrieveNextRow(Vector fields, ResultSet resultSet, AbstractSession session) throws DatabaseException { try { if (resultSet.next()) { return fetchRow(fields, resultSet, resultSet.getMetaData(), session); } else { return null; } } catch (SQLException exception) { DatabaseException commException = processExceptionForCommError(session, exception, null); if (commException != null) throw commException; throw DatabaseException.sqlException(exception, this, session, false); } }
/** * Advance the result set and return a Record populated * with values from the next valid row in the result set. Intended solely * for cursored stream support. */ public AbstractRecord cursorRetrieveNextRow(Vector fields, ResultSet resultSet, AbstractSession session) throws DatabaseException { try { if (resultSet.next()) { return fetchRow(fields, resultSet, resultSet.getMetaData(), session); } else { return null; } } catch (SQLException exception) { DatabaseException commException = processExceptionForCommError(session, exception, null); if (commException != null) throw commException; throw DatabaseException.sqlException(exception, this, session, false); } }
/** * Advance the result set and return a Record populated * with values from the next valid row in the result set. Intended solely * for cursored stream support. */ public AbstractRecord cursorRetrieveNextRow(Vector fields, ResultSet resultSet, AbstractSession session) throws DatabaseException { try { if (resultSet.next()) { return fetchRow(fields, resultSet, resultSet.getMetaData(), session); } else { return null; } } catch (SQLException exception) { DatabaseException commException = processExceptionForCommError(session, exception, null); if (commException != null) throw commException; throw DatabaseException.sqlException(exception, this, session, false); } }
/** * Advance the result set and return a DatabaseRow populated * with values from the next valid row in the result set. Intended solely * for scrollable cursor support. */ public AbstractRecord cursorRetrievePreviousRow(Vector fields, ResultSet resultSet, AbstractSession session) throws DatabaseException { try { if (resultSet.previous()) { return fetchRow(fields, resultSet, resultSet.getMetaData(), session); } else { return null; } } catch (SQLException exception) { DatabaseException commException = processExceptionForCommError(session, exception, null); if (commException != null) throw commException; throw DatabaseException.sqlException(exception, this, session, false); } }
/** * Advance the result set and return a DatabaseRow populated * with values from the next valid row in the result set. Intended solely * for scrollable cursor support. */ public AbstractRecord cursorRetrievePreviousRow(Vector fields, ResultSet resultSet, AbstractSession session) throws DatabaseException { try { if (resultSet.previous()) { return fetchRow(fields, resultSet, resultSet.getMetaData(), session); } else { return null; } } catch (SQLException exception) { DatabaseException commException = processExceptionForCommError(session, exception, null); if (commException != null) throw commException; throw DatabaseException.sqlException(exception, this, session, false); } }
/** * Advance the result set and return a DatabaseRow populated * with values from the next valid row in the result set. Intended solely * for scrollable cursor support. */ public AbstractRecord cursorRetrievePreviousRow(Vector fields, ResultSet resultSet, AbstractSession session) throws DatabaseException { try { if (resultSet.previous()) { return fetchRow(fields, resultSet, resultSet.getMetaData(), session); } else { return null; } } catch (SQLException exception) { DatabaseException commException = processExceptionForCommError(session, exception, null); if (commException != null) throw commException; throw DatabaseException.sqlException(exception, this, session, false); } }
protected Object processResultSet(ResultSet resultSet, DatabaseCall dbCall, PreparedStatement statement, DatabaseAccessor accessor, AbstractSession session) throws SQLException { Object result = null; ResultSetMetaData metaData = resultSet.getMetaData(); session.startOperationProfile(SessionProfiler.ROW_FETCH, dbCall.getQuery(), SessionProfiler.ALL); try { if (dbCall.isOneRowReturned()) { if (resultSet.next()) { result = accessor.fetchRow(dbCall.getFields(), resultSet, metaData, session); if (resultSet.next()) { // Raise more rows event, some apps may interpret as error or warning. if (session.hasEventManager()) { session.getEventManager().moreRowsDetected(dbCall); } } } else { result = null; } } else { Vector results = new Vector(20); while (resultSet.next()) { results.addElement(accessor.fetchRow(dbCall.getFields(), resultSet, metaData, session)); } result = results; } resultSet.close();// This must be closed incase the statement is cached and not closed. } finally { session.endOperationProfile(SessionProfiler.ROW_FETCH, dbCall.getQuery(), SessionProfiler.ALL); } return result; }
/** * Build the given result set into a list objects. Assumes there is an * execute call available and therefore should not be called unless an * execute statement was issued by the user. */ protected List buildResultRecords(ResultSet resultSet) { try { AbstractSession session = (AbstractSession) getActiveSession(); DatabaseAccessor accessor = (DatabaseAccessor) executeCall.getQuery().getAccessor(); executeCall.setFields(null); executeCall.matchFieldOrder(resultSet, accessor, session); ResultSetMetaData metaData = resultSet.getMetaData(); List result = new Vector(); while (resultSet.next()) { result.add(accessor.fetchRow(executeCall.getFields(), executeCall.getFieldsArray(), resultSet, metaData, session)); } // The result set must be closed in case the statement is cached and not closed. resultSet.close(); return result; } catch (Exception e) { setRollbackOnly(); throw new PersistenceException(e); } }
result.addElement(fetchRow(fields, resultSet, metaData, session));
result.addElement(fetchRow(fields, resultSet, metaData, session));
result.addElement(fetchRow(fields, resultSet, metaData, session));
result.addElement(fetchRow(fields, resultSet, metaData, session));
result.addElement(fetchRow(fields, resultSet, metaData, session));
result.addElement(fetchRow(fields, resultSet, metaData, session));
results.addElement(fetchRow(dbCall.getFields(), resultSet, metaData, session)); hasNext = resultSet.next();
results.add(fetchRow(dbCall.getFields(), dbCall.getFieldsArray(), resultSet, metaData, session)); hasNext = resultSet.next();
results.add(fetchRow(dbCall.getFields(), dbCall.getFieldsArray(), resultSet, metaData, session)); hasNext = resultSet.next();