public boolean absolute(int row) throws SQLException { return absolute(row, 0); }
public boolean absolute(int row) throws SQLException { return absolute(row, 0); }
/** * Return the value for output/return parameter given the index * of the parameter in the ResultSet * @param index Index of the parameter to be retrieved. */ Object getOutputParamValue(int index) throws SQLException { if (index <= resultColumns || index > resultColumns + parameters) { throw new TeiidSQLException(JDBCPlugin.Util.getString("StoredProcedureResultsImpl.Invalid_parameter_index__{0}_2", index)); //$NON-NLS-1$ } // Mark the row we're on final int originalRow = getAbsoluteRowNumber(); this.batchResults.absolute(-1); try { return getObjectDirect(index); } finally { this.batchResults.absolute(originalRow); } }
/** * Return the value for output/return parameter given the index * of the parameter in the ResultSet * @param index Index of the parameter to be retrieved. */ Object getOutputParamValue(int index) throws SQLException { if (index <= resultColumns || index > resultColumns + parameters) { throw new TeiidSQLException(JDBCPlugin.Util.getString("StoredProcedureResultsImpl.Invalid_parameter_index__{0}_2", index)); //$NON-NLS-1$ } // Mark the row we're on final int originalRow = getAbsoluteRowNumber(); this.batchResults.absolute(-1); try { return getObjectDirect(index); } finally { this.batchResults.absolute(originalRow); } }
public boolean absolute( int row) throws SQLException { checkClosed(); checkNotForwardOnly(); return batchResults.absolute(row, getOffset()); }
public boolean absolute( int row) throws SQLException { checkClosed(); checkNotForwardOnly(); return batchResults.absolute(row, getOffset()); }
@Test public void testAbsolute2() throws Exception{ //one row batch BatchResults batchResults = getBatchResults(createBatch(1, 1), false); assertFalse(batchResults.absolute(0)); assertTrue(batchResults.absolute(1)); assertTrue(batchResults.absolute(1)); List<Integer> expectedResult = new ArrayList<Integer>(); expectedResult.add(new Integer(1)); assertEquals(batchResults.getCurrentRow(), expectedResult); }
@Test public void testAbsolute4() throws Exception{ //one row batch BatchResults batchResults = getBatchResults(createBatch(1, 1), false); assertTrue(batchResults.absolute(10)); assertTrue(batchResults.absolute(2)); List<Integer> expectedResult = new ArrayList<Integer>(); expectedResult.add(new Integer(2)); assertEquals(batchResults.getCurrentRow(), expectedResult); }
@Test public void testAbsolute5() throws Exception{ //one row batch BatchResults batchResults = getBatchResults(createBatch(1, 1), false); assertTrue(batchResults.absolute(-1)); List<Integer> expectedResult = new ArrayList<Integer>(); expectedResult.add(new Integer(50)); assertEquals(expectedResult, batchResults.getCurrentRow()); assertFalse(batchResults.absolute(-100)); }
@Test public void testAbsolute3() throws Exception{ BatchResults batchResults = getBatchResults(createBatch(1, 10), false); batchResults.setBatchFetcher(new MockBatchFetcher(200)); assertFalse(batchResults.absolute(0)); assertTrue(batchResults.absolute(11)); List<Integer> expectedResult = new ArrayList<Integer>(); expectedResult.add(new Integer(11)); assertEquals(batchResults.getCurrentRow(), expectedResult); assertTrue(batchResults.absolute(1)); expectedResult = new ArrayList<Integer>(); expectedResult.add(new Integer(1)); assertEquals(batchResults.getCurrentRow(), expectedResult); assertTrue(batchResults.absolute(100)); expectedResult = new ArrayList<Integer>(); expectedResult.add(new Integer(100)); assertEquals(batchResults.getCurrentRow(), expectedResult); }
@Test public void testAbsoluteWithLastRow() throws Exception{ Batch batch = new Batch(createBatch(1, 10), 1, 10); batch.setLastRow(50); MockBatchFetcher mbf = new MockBatchFetcher(); mbf.setUseLastRow(true); BatchResults batchResults = new BatchResults(mbf, batch, BatchResults.DEFAULT_SAVED_BATCHES); assertTrue(batchResults.absolute(41)); assertEquals(Arrays.asList(41), batchResults.getCurrentRow()); //check to ensure that we skipped all the other batches assertEquals(Arrays.asList(41), mbf.batchCalls); }
@Test public void testBatching() throws Exception { BatchResults batchResults = getBatchResults(createBatch(1, 10), false); MockBatchFetcher batchFetcher = new MockBatchFetcher(60); batchResults.setBatchFetcher(batchFetcher); for(int i=0; i<45; i++) { assertTrue(batchResults.next()); } for(int i=0; i<44; i++) { assertTrue(batchResults.previous()); assertEquals(new Integer(44 - i), batchResults.getCurrentRow().get(0)); } // verify batch calls checkResults(new int[] { // going forwards - end > begin 11, 21, 31, 41, // going backwards - begin > end // last 3 batches were saved, only need the first 2 again 20, 10, }, batchFetcher.batchCalls); assertTrue(batchResults.absolute(50)); assertEquals(new Integer(50), batchResults.getCurrentRow().get(0)); }