org.springframework.jdbc.LobRetrievalFailureException Java Examples

The following examples show how to use org.springframework.jdbc.LobRetrievalFailureException. 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
Source File: AbstractLobStreamingResultSetExtractor.java    From spring-analysis-note with MIT License 6 votes vote down vote up
/**
 * 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
Source File: AbstractLobStreamingResultSetExtractor.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * 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
Source File: AbstractLobStreamingResultSetExtractor.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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
Source File: AbstractLobStreamingResultSetExtractor.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * 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
Source File: DefaultImageDatabase.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@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
Source File: AbstractLobStreamingResultSetExtractor.java    From effectivejava with Apache License 2.0 6 votes vote down vote up
/**
 * 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 File: LobSupportTests.java    From spring-analysis-note with 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 File: LobSupportTests.java    From java-technology-stack with 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 File: LobSupportTests.java    From spring4-understanding with 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 File: LobSupportTests.java    From effectivejava with 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);
}