Java Code Examples for org.springframework.jdbc.LobRetrievalFailureException

The following examples show how to use org.springframework.jdbc.LobRetrievalFailureException. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 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;
}
 
Example 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;
}
 
Example 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;
}
 
Example 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;
}
 
Example 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);
					}
				}
			}
	);
}
 
Example 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;
}
 
Example 7
Source Project: spring-analysis-note   Source File: LobSupportTests.java    License: MIT License 5 votes vote down vote up
@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));
}
 
Example 8
Source Project: java-technology-stack   Source File: LobSupportTests.java    License: MIT License 5 votes vote down vote up
@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);
}
 
Example 9
Source Project: spring4-understanding   Source File: LobSupportTests.java    License: Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 10
Source Project: effectivejava   Source File: LobSupportTests.java    License: Apache License 2.0 5 votes vote down vote up
@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);
}