Polishing
This commit is contained in:
parent
cc06183668
commit
e8a0ef0206
|
|
@ -39,18 +39,19 @@ import org.springframework.jdbc.core.namedparam.SqlParameterSource;
|
|||
* the JDBC driver. Since we rely on the JDBC driver, this "auto-detection"
|
||||
* can only be used for databases that are known to provide accurate meta data.
|
||||
* These currently include Derby, MySQL, Microsoft SQL Server, Oracle, DB2,
|
||||
* Sybase and PostgreSQL. For any other databases you are required to declare all
|
||||
* parameters explicitly. You can of course declare all parameters explicitly even
|
||||
* if the database provides the necessary meta data. In that case your declared
|
||||
* parameters will take precedence. You can also turn off any meta data processing
|
||||
* if you want to use parameter names that do not match what is declared during
|
||||
* the stored procedure compilation.
|
||||
* Sybase and PostgreSQL. For any other databases you are required to declare
|
||||
* all parameters explicitly. You can of course declare all parameters
|
||||
* explicitly even if the database provides the necessary meta data. In that
|
||||
* case your declared parameters will take precedence. You can also turn off
|
||||
* any metadata processing if you want to use parameter names that do not
|
||||
* match what is declared during the stored procedure compilation.
|
||||
*
|
||||
* <p>The actual insert is being handled using Spring's
|
||||
* {@link org.springframework.jdbc.core.JdbcTemplate}.
|
||||
*
|
||||
* <p>Many of the configuration methods return the current instance of the SimpleJdbcCall
|
||||
* to provide the ability to chain multiple ones together in a "fluent" interface style.
|
||||
* <p>Many of the configuration methods return the current instance of the
|
||||
* SimpleJdbcCall in order to provide the ability to chain multiple ones
|
||||
* together in a "fluent" interface style.
|
||||
*
|
||||
* @author Thomas Risberg
|
||||
* @author Stephane Nicoll
|
||||
|
|
@ -61,8 +62,8 @@ import org.springframework.jdbc.core.namedparam.SqlParameterSource;
|
|||
public class SimpleJdbcCall extends AbstractJdbcCall implements SimpleJdbcCallOperations {
|
||||
|
||||
/**
|
||||
* Constructor that takes one parameter with the JDBC DataSource to use when creating the
|
||||
* JdbcTemplate.
|
||||
* Constructor that takes one parameter with the JDBC DataSource to use when
|
||||
* creating the underlying JdbcTemplate.
|
||||
* @param dataSource the {@code DataSource} to use
|
||||
* @see org.springframework.jdbc.core.JdbcTemplate#setDataSource
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.jdbc.core.simple;
|
||||
|
||||
import java.sql.Connection;
|
||||
|
|
@ -29,11 +45,14 @@ import static org.mockito.BDDMockito.*;
|
|||
public class CallMetaDataContextTests {
|
||||
|
||||
private DataSource dataSource;
|
||||
|
||||
private Connection connection;
|
||||
|
||||
private DatabaseMetaData databaseMetaData;
|
||||
|
||||
private CallMetaDataContext context = new CallMetaDataContext();
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
connection = mock(Connection.class);
|
||||
|
|
@ -48,6 +67,7 @@ public class CallMetaDataContextTests {
|
|||
verify(connection).close();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testMatchParameterValuesAndSqlInOutParameters() throws Exception {
|
||||
final String TABLE = "customers";
|
||||
|
|
|
|||
|
|
@ -49,13 +49,17 @@ import static org.springframework.tests.Matchers.*;
|
|||
*/
|
||||
public class SimpleJdbcCallTests {
|
||||
|
||||
private Connection connection;
|
||||
|
||||
private DatabaseMetaData databaseMetaData;
|
||||
|
||||
private DataSource dataSource;
|
||||
|
||||
private CallableStatement callableStatement;
|
||||
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
private Connection connection;
|
||||
private DatabaseMetaData databaseMetaData;
|
||||
private DataSource dataSource;
|
||||
private CallableStatement callableStatement;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
|
@ -67,6 +71,7 @@ public class SimpleJdbcCallTests {
|
|||
given(dataSource.getConnection()).willReturn(connection);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testNoSuchStoredProcedure() throws Exception {
|
||||
final String NO_SUCH_PROC = "x";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -39,12 +39,15 @@ import static org.mockito.BDDMockito.*;
|
|||
*/
|
||||
public class SimpleJdbcInsertTests {
|
||||
|
||||
private Connection connection;
|
||||
|
||||
private DatabaseMetaData databaseMetaData;
|
||||
|
||||
private DataSource dataSource;
|
||||
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
private Connection connection;
|
||||
private DatabaseMetaData databaseMetaData;
|
||||
private DataSource dataSource;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
|
@ -60,6 +63,7 @@ public class SimpleJdbcInsertTests {
|
|||
verify(connection).close();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testNoSuchTable() throws Exception {
|
||||
ResultSet resultSet = mock(ResultSet.class);
|
||||
|
|
@ -81,4 +85,5 @@ public class SimpleJdbcInsertTests {
|
|||
verify(resultSet).close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -43,11 +43,14 @@ import static org.mockito.BDDMockito.*;
|
|||
public class TableMetaDataContextTests {
|
||||
|
||||
private Connection connection;
|
||||
|
||||
private DataSource dataSource;
|
||||
|
||||
private DatabaseMetaData databaseMetaData;
|
||||
|
||||
private TableMetaDataContext context = new TableMetaDataContext();
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
connection = mock(Connection.class);
|
||||
|
|
@ -57,9 +60,6 @@ public class TableMetaDataContextTests {
|
|||
given(dataSource.getConnection()).willReturn(connection);
|
||||
}
|
||||
|
||||
public void verifyClosed() throws Exception {
|
||||
verify(connection).close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMatchInParametersAndSqlTypeInfoWrapping() throws Exception {
|
||||
|
|
@ -153,4 +153,5 @@ public class TableMetaDataContextTests {
|
|||
verify(metaDataResultSet).close();
|
||||
verify(columnsResultSet).close();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue