Java Code Examples for org.springframework.jdbc.core.JdbcTemplate#setSkipUndeclaredResults()
The following examples show how to use
org.springframework.jdbc.core.JdbcTemplate#setSkipUndeclaredResults() .
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: StoredProcedureTests.java From spring-analysis-note with MIT License | 5 votes |
@Test @SuppressWarnings("unchecked") public void testStoredProcedureSkippingUndeclaredResults() throws Exception { ResultSet resultSet = mock(ResultSet.class); given(resultSet.next()).willReturn(true, true, false); given(resultSet.getString(2)).willReturn("Foo", "Bar"); given(callableStatement.execute()).willReturn(true); given(callableStatement.getUpdateCount()).willReturn(-1); given(callableStatement.getResultSet()).willReturn(resultSet); given(callableStatement.getMoreResults()).willReturn(true, false); given(callableStatement.getUpdateCount()).willReturn(-1, -1); given(connection.prepareCall("{call " + StoredProcedureWithResultSetMapped.SQL + "()}") ).willReturn(callableStatement); JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); jdbcTemplate.setSkipUndeclaredResults(true); StoredProcedureWithResultSetMapped sproc = new StoredProcedureWithResultSetMapped( jdbcTemplate); Map<String, Object> res = sproc.execute(); assertEquals("incorrect number of returns", 1, res.size()); List<String> rs1 = (List<String>) res.get("rs"); assertEquals(2, rs1.size()); assertEquals("Foo", rs1.get(0)); assertEquals("Bar", rs1.get(1)); verify(resultSet).close(); }
Example 2
Source File: StoredProcedureTests.java From java-technology-stack with MIT License | 5 votes |
@Test @SuppressWarnings("unchecked") public void testStoredProcedureSkippingUndeclaredResults() throws Exception { ResultSet resultSet = mock(ResultSet.class); given(resultSet.next()).willReturn(true, true, false); given(resultSet.getString(2)).willReturn("Foo", "Bar"); given(callableStatement.execute()).willReturn(true); given(callableStatement.getUpdateCount()).willReturn(-1); given(callableStatement.getResultSet()).willReturn(resultSet); given(callableStatement.getMoreResults()).willReturn(true, false); given(callableStatement.getUpdateCount()).willReturn(-1, -1); given(connection.prepareCall("{call " + StoredProcedureWithResultSetMapped.SQL + "()}") ).willReturn(callableStatement); JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); jdbcTemplate.setSkipUndeclaredResults(true); StoredProcedureWithResultSetMapped sproc = new StoredProcedureWithResultSetMapped( jdbcTemplate); Map<String, Object> res = sproc.execute(); assertEquals("incorrect number of returns", 1, res.size()); List<String> rs1 = (List<String>) res.get("rs"); assertEquals(2, rs1.size()); assertEquals("Foo", rs1.get(0)); assertEquals("Bar", rs1.get(1)); verify(resultSet).close(); }
Example 3
Source File: StoredProcedureTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test @SuppressWarnings("unchecked") public void testStoredProcedureSkippingUndeclaredResults() throws Exception { ResultSet resultSet = mock(ResultSet.class); given(resultSet.next()).willReturn(true, true, false); given(resultSet.getString(2)).willReturn("Foo", "Bar"); given(callableStatement.execute()).willReturn(true); given(callableStatement.getUpdateCount()).willReturn(-1); given(callableStatement.getResultSet()).willReturn(resultSet); given(callableStatement.getMoreResults()).willReturn(true, false); given(callableStatement.getUpdateCount()).willReturn(-1, -1); given(connection.prepareCall("{call " + StoredProcedureWithResultSetMapped.SQL + "()}") ).willReturn(callableStatement); JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); jdbcTemplate.setSkipUndeclaredResults(true); StoredProcedureWithResultSetMapped sproc = new StoredProcedureWithResultSetMapped( jdbcTemplate); Map<String, Object> res = sproc.execute(); assertEquals("incorrect number of returns", 1, res.size()); List<String> rs1 = (List<String>) res.get("rs"); assertEquals(2, rs1.size()); assertEquals("Foo", rs1.get(0)); assertEquals("Bar", rs1.get(1)); verify(resultSet).close(); }
Example 4
Source File: StoredProcedureTests.java From effectivejava with Apache License 2.0 | 5 votes |
@Test @SuppressWarnings("unchecked") public void testStoredProcedureSkippingUndeclaredResults() throws Exception { ResultSet resultSet = mock(ResultSet.class); given(resultSet.next()).willReturn(true, true, false); given(resultSet.getString(2)).willReturn("Foo", "Bar"); given(callableStatement.execute()).willReturn(true); given(callableStatement.getUpdateCount()).willReturn(-1); given(callableStatement.getResultSet()).willReturn(resultSet); given(callableStatement.getMoreResults()).willReturn(true, false); given(callableStatement.getUpdateCount()).willReturn(-1, -1); given(connection.prepareCall("{call " + StoredProcedureWithResultSetMapped.SQL + "()}") ).willReturn(callableStatement); JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); jdbcTemplate.setSkipUndeclaredResults(true); StoredProcedureWithResultSetMapped sproc = new StoredProcedureWithResultSetMapped( jdbcTemplate); Map<String, Object> res = sproc.execute(); assertEquals("incorrect number of returns", 1, res.size()); List<String> rs1 = (List<String>) res.get("rs"); assertEquals(2, rs1.size()); assertEquals("Foo", rs1.get(0)); assertEquals("Bar", rs1.get(1)); verify(resultSet).close(); }