Java源码示例:org.springframework.jdbc.LobRetrievalFailureException

示例1
/**
 * Delegates to handleNoRowFound, handleMultipleRowsFound and streamData,
 * according to the ResultSet state. Converts an IOException thrown by
 * streamData to a LobRetrievalFailureException.
 * @see #handleNoRowFound
 * @see #handleMultipleRowsFound
 * @see #streamData
 * @see org.springframework.jdbc.LobRetrievalFailureException
 */
@Override
@Nullable
public final T extractData(ResultSet rs) throws SQLException, DataAccessException {
	if (!rs.next()) {
		handleNoRowFound();
	}
	else {
		try {
			streamData(rs);
			if (rs.next()) {
				handleMultipleRowsFound();
			}
		}
		catch (IOException ex) {
			throw new LobRetrievalFailureException("Couldn't stream LOB content", ex);
		}
	}
	return null;
}
 
示例2
/**
 * Delegates to handleNoRowFound, handleMultipleRowsFound and streamData,
 * according to the ResultSet state. Converts an IOException thrown by
 * streamData to a LobRetrievalFailureException.
 * @see #handleNoRowFound
 * @see #handleMultipleRowsFound
 * @see #streamData
 * @see org.springframework.jdbc.LobRetrievalFailureException
 */
@Override
@Nullable
public final T extractData(ResultSet rs) throws SQLException, DataAccessException {
	if (!rs.next()) {
		handleNoRowFound();
	}
	else {
		try {
			streamData(rs);
			if (rs.next()) {
				handleMultipleRowsFound();
			}
		}
		catch (IOException ex) {
			throw new LobRetrievalFailureException("Couldn't stream LOB content", ex);
		}
	}
	return null;
}
 
示例3
/**
 * Delegates to handleNoRowFound, handleMultipleRowsFound and streamData,
 * according to the ResultSet state. Converts an IOException thrown by
 * streamData to a LobRetrievalFailureException.
 * @see #handleNoRowFound
 * @see #handleMultipleRowsFound
 * @see #streamData
 * @see org.springframework.jdbc.LobRetrievalFailureException
 */
@Override
public final T extractData(ResultSet rs) throws SQLException, DataAccessException {
	if (!rs.next()) {
		handleNoRowFound();
	}
	else {
		try {
			streamData(rs);
			if (rs.next()) {
				handleMultipleRowsFound();
			}
		}
		catch (IOException ex) {
			throw new LobRetrievalFailureException("Couldn't stream LOB content", ex);
		}
	}
	return null;
}
 
示例4
/**
 * Delegates to handleNoRowFound, handleMultipleRowsFound and streamData,
 * according to the ResultSet state. Converts an IOException thrown by
 * streamData to a LobRetrievalFailureException.
 * @see #handleNoRowFound
 * @see #handleMultipleRowsFound
 * @see #streamData
 * @see org.springframework.jdbc.LobRetrievalFailureException
 */
@Override
public final T extractData(ResultSet rs) throws SQLException, DataAccessException {
	if (!rs.next()) {
		handleNoRowFound();
	}
	else {
		try {
			streamData(rs);
			if (rs.next()) {
				handleMultipleRowsFound();
			}
		}
		catch (IOException ex) {
			throw new LobRetrievalFailureException("Couldn't stream LOB content", ex);
		}
	}
	return null;
}
 
示例5
@Transactional(readOnly=true)
public void streamImage(final String name, final OutputStream contentStream) throws DataAccessException {
	getJdbcTemplate().query(
			"SELECT content FROM imagedb WHERE image_name=?", new Object[] {name},
			new AbstractLobStreamingResultSetExtractor() {
				protected void handleNoRowFound() throws LobRetrievalFailureException {
					throw new EmptyResultDataAccessException(
					    "Image with name '" + name + "' not found in database", 1);
				}
				public void streamData(ResultSet rs) throws SQLException, IOException {
					InputStream is = lobHandler.getBlobAsBinaryStream(rs, 1);
					if (is != null) {
						FileCopyUtils.copy(is, contentStream);
					}
				}
			}
	);
}
 
示例6
/**
 * Delegates to handleNoRowFound, handleMultipleRowsFound and streamData,
 * according to the ResultSet state. Converts an IOException thrown by
 * streamData to a LobRetrievalFailureException.
 * @see #handleNoRowFound
 * @see #handleMultipleRowsFound
 * @see #streamData
 * @see org.springframework.jdbc.LobRetrievalFailureException
 */
@Override
public final T extractData(ResultSet rs) throws SQLException, DataAccessException {
	if (!rs.next()) {
		handleNoRowFound();
	}
	else {
		try {
			streamData(rs);
			if (rs.next()) {
				handleMultipleRowsFound();
			}
		}
		catch (IOException ex) {
			throw new LobRetrievalFailureException("Couldn't stream LOB content", ex);
		}
	}
	return null;
}
 
示例7
@Test
public void testAbstractLobStreamingResultSetExtractorCorrectException()
		throws SQLException {
	ResultSet rset = mock(ResultSet.class);
	given(rset.next()).willReturn(true);
	AbstractLobStreamingResultSetExtractor<Void> lobRse = getResultSetExtractor(true);
	assertThatExceptionOfType(LobRetrievalFailureException.class).isThrownBy(() ->
			lobRse.extractData(rset));
}
 
示例8
@Test
public void testAbstractLobStreamingResultSetExtractorCorrectException()
		throws SQLException {
	ResultSet rset = mock(ResultSet.class);
	given(rset.next()).willReturn(true);
	AbstractLobStreamingResultSetExtractor<Void> lobRse = getResultSetExtractor(true);
	thrown.expect(LobRetrievalFailureException.class);
	lobRse.extractData(rset);
}
 
示例9
@Test
public void testAbstractLobStreamingResultSetExtractorCorrectException()
		throws SQLException {
	ResultSet rset = mock(ResultSet.class);
	given(rset.next()).willReturn(true);
	AbstractLobStreamingResultSetExtractor<Void> lobRse = getResultSetExtractor(true);
	thrown.expect(LobRetrievalFailureException.class);
	lobRse.extractData(rset);
}
 
示例10
@Test
public void testAbstractLobStreamingResultSetExtractorCorrectException()
		throws SQLException {
	ResultSet rset = mock(ResultSet.class);
	given(rset.next()).willReturn(true);
	AbstractLobStreamingResultSetExtractor<Void> lobRse = getResultSetExtractor(true);
	thrown.expect(LobRetrievalFailureException.class);
	lobRse.extractData(rset);
}