SimpleJdbcCall返回null

时间:2017-03-14 07:47:09

标签: java sql-server spring spring-boot spring-jdbc

我有下面的代码试图调用存储过程rp_report。但它返回空指针异常。有关详细信息,请参阅下面的日志和代码。
我怀疑错误在输入参数中,类型为LocalDate。但我找不到任何指示为什么会发生此错误的日志。此应用程序使用SpringBoot和SimpleJdbcCall来调用存储过程。

非常感谢任何帮助。

import java.time.LocalDate;
import java.util.Map;

import org.apache.log4j.Logger;
import org.octopoda.model.RptByCourier;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
import org.springframework.jdbc.core.simple.SimpleJdbcCall;
import org.springframework.stereotype.Repository;


@Repository
public class RptByCourierSPRepo {

    private static final Logger logger = Logger.getLogger(RptByCourierSPRepo.class);

    @Autowired
    private SimpleJdbcCall spCall;


    public RptByCourier callRptByCourierSP(LocalDate startDate, LocalDate endDate, Integer branchId) {

        logger.info("Initiate Store Procedure rp_report");

        RptByCourier spReturn = new RptByCourier();
        spCall.withCatalogName("dbo"); <----Newly Added
        spCall.withProcedureName("Rp_Report");

        SqlParameterSource sqlParam = new MapSqlParameterSource()
                .addValue("StartDate", startDate)
                .addValue("EndDate", endDate)
                .addValue("Branch", branchId);


        Map<String, Object> spResult = Objects.requireNonNull(spCall.execute(sqlParam), "spCall.execute() returned null");

/**Setters here Truncated*/
        return spReturn;
    }
}

截断日志

2017-03-14 14:27:54.291 DEBUG 8592 --- [           main] o.s.c.e.PropertySourcesPropertyResolver  : Could not find key 'spring.liveBeansView.mbeanDomain' in any property source
2017-03-14 14:27:54.384  INFO 8592 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2017-03-14 14:27:54.400 DEBUG 8592 --- [           main] o.s.w.c.s.StandardServletEnvironment     : Adding [server.ports] PropertySource with highest search precedence
2017-03-14 14:27:54.400  INFO 8592 --- [           main] org.octopoda.Octopoda              : Started Octopoda in 6.652 seconds (JVM running for 7.188)
2017-03-14 14:28:48.742 DEBUG 8592 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing servlet 'dispatcherServlet'
2017-03-14 14:28:48.744  INFO 8592 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring FrameworkServlet 'dispatcherServlet'
2017-03-14 14:28:48.744  INFO 8592 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization started
2017-03-14 14:28:48.744 DEBUG 8592 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'multipartResolver'
2017-03-14 14:28:48.744 DEBUG 8592 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Using MultipartResolver [org.springframework.web.multipart.support.StandardServletMultipartResolver@3aea852b]
2017-03-14 14:28:48.745 DEBUG 8592 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Creating instance of bean 'org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver'
2017-03-14 14:28:48.748 DEBUG 8592 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
2017-03-14 14:28:48.749 DEBUG 8592 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Finished creating instance of bean 'org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver'
2017-03-14 14:28:48.749 DEBUG 8592 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Unable to locate LocaleResolver with name 'localeResolver': using default [org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver@41cc2514]
2017-03-14 14:28:48.750 DEBUG 8592 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Creating instance of bean 'org.springframework.web.servlet.theme.FixedThemeResolver'
2017-03-14 14:28:48.755 DEBUG 8592 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
2017-03-14 14:28:48.755 DEBUG 8592 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Finished creating instance of bean 'org.springframework.web.servlet.theme.FixedThemeResolver'
2017-03-14 14:28:48.755 DEBUG 8592 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Unable to locate ThemeResolver with name 'themeResolver': using default [org.springframework.web.servlet.theme.FixedThemeResolver@2c1b9387]
2017-03-14 14:28:48.755 DEBUG 8592 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'requestMappingHandlerMapping'
2017-03-14 14:28:48.755 DEBUG 8592 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'viewControllerHandlerMapping'
2017-03-14 14:28:48.755 DEBUG 8592 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'beanNameHandlerMapping'
2017-03-14 14:28:48.755 DEBUG 8592 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'resourceHandlerMapping'
2017-03-14 14:28:48.755 DEBUG 8592 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'defaultServletHandlerMapping'
2017-03-14 14:28:48.755 DEBUG 8592 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'faviconHandlerMapping'
2017-03-14 14:28:48.756 DEBUG 8592 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'requestMappingHandlerAdapter'
2017-03-14 14:28:48.756 DEBUG 8592 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'httpRequestHandlerAdapter'
2017-03-14 14:28:48.756 DEBUG 8592 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'simpleControllerHandlerAdapter'
2017-03-14 14:28:48.756 DEBUG 8592 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'errorAttributes'
2017-03-14 14:28:48.756 DEBUG 8592 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'handlerExceptionResolver'
2017-03-14 14:28:48.756 DEBUG 8592 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Creating instance of bean 'org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator'
2017-03-14 14:28:48.759 DEBUG 8592 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
2017-03-14 14:28:48.759 DEBUG 8592 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Finished creating instance of bean 'org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator'
2017-03-14 14:28:48.759 DEBUG 8592 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Unable to locate RequestToViewNameTranslator with name 'viewNameTranslator': using default [org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator@63299382]
2017-03-14 14:28:48.759 DEBUG 8592 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'beanNameViewResolver'
2017-03-14 14:28:48.759 DEBUG 8592 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'mvcViewResolver'
2017-03-14 14:28:48.759 DEBUG 8592 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'defaultViewResolver'
2017-03-14 14:28:48.759 DEBUG 8592 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'viewResolver'
2017-03-14 14:28:48.760 DEBUG 8592 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Creating instance of bean 'org.springframework.web.servlet.support.SessionFlashMapManager'
2017-03-14 14:28:48.766 DEBUG 8592 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
2017-03-14 14:28:48.766 DEBUG 8592 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Finished creating instance of bean 'org.springframework.web.servlet.support.SessionFlashMapManager'
2017-03-14 14:28:48.766 DEBUG 8592 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Unable to locate FlashMapManager with name 'flashMapManager': using default [org.springframework.web.servlet.support.SessionFlashMapManager@13233d1e]
2017-03-14 14:28:48.766 DEBUG 8592 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Published WebApplicationContext of servlet 'dispatcherServlet' as ServletContext attribute with name [org.springframework.web.servlet.FrameworkServlet.CONTEXT.dispatcherServlet]
2017-03-14 14:28:48.766  INFO 8592 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization completed in 22 ms
2017-03-14 14:28:48.766 DEBUG 8592 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Servlet 'dispatcherServlet' configured successfully
2017-03-14 14:28:48.785 DEBUG 8592 --- [nio-8080-exec-1] o.s.b.w.f.OrderedRequestContextFilter    : Bound request context to thread: org.apache.catalina.connector.RequestFacade@37efd08a
2017-03-14 14:28:48.787 DEBUG 8592 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : DispatcherServlet with name 'dispatcherServlet' processing GET request for [/v1/viewCourierReport]
2017-03-14 14:28:48.792 DEBUG 8592 --- [nio-8080-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /v1/viewCourierReport
2017-03-14 14:28:48.796 DEBUG 8592 --- [nio-8080-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Returning handler method [public org.octopoda.model.RptByCourier org.octopoda.rest.RptByCourierRest.viewRptByCourier(java.lang.String,java.lang.String,java.lang.Integer)]
2017-03-14 14:28:48.796 DEBUG 8592 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'rptByCourierRest'
2017-03-14 14:28:48.796 DEBUG 8592 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Last-Modified value for [/v1/viewCourierReport] is: -1
2017-03-14 14:28:48.827  INFO 8592 --- [nio-8080-exec-1] o.octopoda.rest.RptByCourierRest   : Starting Rest API --- view report by courier
2017-03-14 14:28:48.828  INFO 8592 --- [nio-8080-exec-1] o.octopoda.rest.RptByCourierRest   : Start date:2015-01-01 End Date: 2015-01-02 Branch: 213
2017-03-14 14:28:48.839  INFO 8592 --- [nio-8080-exec-1] o.octopoda.rest.RptByCourierRest   : Converted StartDate: 2015-01-01 Converted EndDate: 2015-01-01
2017-03-14 14:28:48.854  INFO 8592 --- [nio-8080-exec-1] o.f.o.repository.RptByCourierSPRepo      : Initiate Store Procedure Rp_Report
2017-03-14 14:28:48.856 DEBUG 8592 --- [nio-8080-exec-1] o.s.jdbc.core.simple.SimpleJdbcCall      : JdbcCall call not compiled before execution - invoking compile
2017-03-14 14:28:48.868 DEBUG 8592 --- [nio-8080-exec-1] o.s.jdbc.datasource.DataSourceUtils      : Fetching JDBC Connection from DataSource
2017-03-14 14:28:48.869 DEBUG 8592 --- [nio-8080-exec-1] o.s.j.d.DriverManagerDataSource          : Creating new JDBC DriverManager Connection to [jdbc:sqlserver://localhost:1433;DatabaseName=Test]
2017-03-14 14:28:49.625 DEBUG 8592 --- [nio-8080-exec-1] o.s.j.c.m.CallMetaDataProviderFactory    : Using org.springframework.jdbc.core.metadata.SqlServerCallMetaDataProvider
2017-03-14 14:28:49.625 DEBUG 8592 --- [nio-8080-exec-1] o.s.j.c.metadata.CallMetaDataProvider    : Retrieving metadata for null/null/Rp_Report
2017-03-14 14:28:49.668 DEBUG 8592 --- [nio-8080-exec-1] o.s.j.c.metadata.CallMetaDataProvider    : Retrieved metadata: @RETURN_VALUE 5 4 int false
2017-03-14 14:28:49.668 DEBUG 8592 --- [nio-8080-exec-1] o.s.j.c.metadata.CallMetaDataProvider    : Retrieved metadata: @StartDate 1 93 datetime true
2017-03-14 14:28:49.668 DEBUG 8592 --- [nio-8080-exec-1] o.s.j.c.metadata.CallMetaDataProvider    : Retrieved metadata: @EndDate 1 93 datetime true
2017-03-14 14:28:49.668 DEBUG 8592 --- [nio-8080-exec-1] o.s.j.c.metadata.CallMetaDataProvider    : Retrieved metadata: @Branch 1 4 int true
2017-03-14 14:28:49.668 DEBUG 8592 --- [nio-8080-exec-1] o.s.jdbc.datasource.DataSourceUtils      : Returning JDBC Connection to DataSource
2017-03-14 14:28:49.669 DEBUG 8592 --- [nio-8080-exec-1] o.s.j.core.metadata.CallMetaDataContext  : Bypassing metadata return parameter for '@RETURN_VALUE'
2017-03-14 14:28:49.669 DEBUG 8592 --- [nio-8080-exec-1] o.s.j.core.metadata.CallMetaDataContext  : Added metadata in parameter for 'StartDate'
2017-03-14 14:28:49.669 DEBUG 8592 --- [nio-8080-exec-1] o.s.j.core.metadata.CallMetaDataContext  : Added metadata in parameter for 'EndDate'
2017-03-14 14:28:49.669 DEBUG 8592 --- [nio-8080-exec-1] o.s.j.core.metadata.CallMetaDataContext  : Added metadata in parameter for 'Branch'
2017-03-14 14:28:49.669 DEBUG 8592 --- [nio-8080-exec-1] o.s.jdbc.core.simple.SimpleJdbcCall      : Compiled stored procedure. Call string is [{call Rp_Report(?, ?, ?)}]
2017-03-14 14:28:49.670 DEBUG 8592 --- [nio-8080-exec-1] o.s.jdbc.core.simple.SimpleJdbcCall      : SqlCall for procedure [Rp_Report] compiled
2017-03-14 14:28:49.671 DEBUG 8592 --- [nio-8080-exec-1] o.s.j.core.metadata.CallMetaDataContext  : Matching [EndDate, StartDate, Branch] with [StartDate, Branch, EndDate]
2017-03-14 14:28:49.671 DEBUG 8592 --- [nio-8080-exec-1] o.s.j.core.metadata.CallMetaDataContext  : Found match for [StartDate, EndDate, Branch]
2017-03-14 14:28:49.673 DEBUG 8592 --- [nio-8080-exec-1] o.s.jdbc.core.simple.SimpleJdbcCall      : The following parameters are used for call {call Rp_Report(?, ?, ?)} with {StartDate=org.springframework.jdbc.core.SqlParameterValue@19fe94e7, EndDate=org.springframework.jdbc.core.SqlParameterValue@774c5ba3, Branch=org.springframework.jdbc.core.SqlParameterValue@391238a8}
2017-03-14 14:28:49.673 DEBUG 8592 --- [nio-8080-exec-1] o.s.jdbc.core.simple.SimpleJdbcCall      : 1: StartDate, SQL type 93, type name null, parameter class [org.springframework.jdbc.core.SqlParameter]
2017-03-14 14:28:49.673 DEBUG 8592 --- [nio-8080-exec-1] o.s.jdbc.core.simple.SimpleJdbcCall      : 2: EndDate, SQL type 93, type name null, parameter class [org.springframework.jdbc.core.SqlParameter]
2017-03-14 14:28:49.673 DEBUG 8592 --- [nio-8080-exec-1] o.s.jdbc.core.simple.SimpleJdbcCall      : 3: Branch, SQL type 4, type name null, parameter class [org.springframework.jdbc.core.SqlParameter]
2017-03-14 14:28:49.673 DEBUG 8592 --- [nio-8080-exec-1] o.s.jdbc.core.JdbcTemplate               : Calling stored procedure [{call Rp_Report(?, ?, ?)}]
2017-03-14 14:28:49.674 DEBUG 8592 --- [nio-8080-exec-1] o.s.jdbc.datasource.DataSourceUtils      : Fetching JDBC Connection from DataSource
2017-03-14 14:28:49.674 DEBUG 8592 --- [nio-8080-exec-1] o.s.j.d.DriverManagerDataSource          : Creating new JDBC DriverManager Connection to [jdbc:sqlserver://localhost:1433;DatabaseName=Test]
2017-03-14 14:28:49.715 DEBUG 8592 --- [nio-8080-exec-1] o.s.jdbc.core.StatementCreatorUtils      : Overriding type info with runtime info from SqlParameterValue: column index 1, SQL type -151, type name null
2017-03-14 14:28:49.718 DEBUG 8592 --- [nio-8080-exec-1] o.s.jdbc.core.StatementCreatorUtils      : Overriding type info with runtime info from SqlParameterValue: column index 2, SQL type -151, type name null
2017-03-14 14:28:49.719 DEBUG 8592 --- [nio-8080-exec-1] o.s.jdbc.core.StatementCreatorUtils      : Overriding type info with runtime info from SqlParameterValue: column index 3, SQL type 4, type name null
2017-03-14 14:28:49.934 DEBUG 8592 --- [nio-8080-exec-1] o.s.jdbc.core.JdbcTemplate               : CallableStatement.execute() returned 'true'
2017-03-14 14:28:49.934 DEBUG 8592 --- [nio-8080-exec-1] o.s.jdbc.core.JdbcTemplate               : CallableStatement.getUpdateCount() returned -1
2017-03-14 14:28:49.935 DEBUG 8592 --- [nio-8080-exec-1] o.s.jdbc.core.JdbcTemplate               : Added default SqlReturnResultSet parameter named '#result-set-1'
2017-03-14 14:28:49.936 DEBUG 8592 --- [nio-8080-exec-1] o.s.jdbc.core.JdbcTemplate               : CallableStatement.getUpdateCount() returned -1
2017-03-14 14:28:49.937 DEBUG 8592 --- [nio-8080-exec-1] o.s.jdbc.datasource.DataSourceUtils      : Returning JDBC Connection to DataSource
2017-03-14 14:28:49.937  INFO 8592 --- [nio-8080-exec-1] o.f.o.repository.RptByCourierSPRepo      : ======Contents of SP Report by Courier=========
2017-03-14 14:28:49.937  INFO 8592 --- [nio-8080-exec-1] o.f.o.repository.RptByCourierSPRepo      : Key: #result-set-1 Value: []
2017-03-14 14:28:49.939 DEBUG 8592 --- [nio-8080-exec-1] .m.m.a.ExceptionHandlerExceptionResolver : Resolving exception from handler [public org.octopoda.model.RptByCourier org.octopoda.rest.RptByCourierRest.viewRptByCourier(java.lang.String,java.lang.String,java.lang.Integer)]: java.lang.NullPointerException
2017-03-14 14:28:49.941 DEBUG 8592 --- [nio-8080-exec-1] .w.s.m.a.ResponseStatusExceptionResolver : Resolving exception from handler [public org.octopoda.model.RptByCourier org.octopoda.rest.RptByCourierRest.viewRptByCourier(java.lang.String,java.lang.String,java.lang.Integer)]: java.lang.NullPointerException
2017-03-14 14:28:49.941 DEBUG 8592 --- [nio-8080-exec-1] .w.s.m.s.DefaultHandlerExceptionResolver : Resolving exception from handler [public org.octopoda.model.RptByCourier org.octopoda.rest.RptByCourierRest.viewRptByCourier(java.lang.String,java.lang.String,java.lang.Integer)]: java.lang.NullPointerException
2017-03-14 14:28:49.946 DEBUG 8592 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Could not complete request

java.lang.NullPointerException: null
    at org.octopoda.repository.RptByCourierSPRepo.callRptByCourierSP(RptByCourierSPRepo.java:66) ~[classes/:na]
    at org.octopoda.repository.RptByCourierSPRepo$$FastClassBySpringCGLIB$$c2845390.invoke(<generated>) ~[classes/:na]
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) ~[spring-core-4.3.2.RELEASE.jar:4.3.2.RELEASE]
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720) ~[spring-aop-4.3.2.RELEASE.jar:4.3.2.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[spring-aop-4.3.2.RELEASE.jar:4.3.2.RELEASE]

这是提及错误的代码行

的行
java.lang.NullPointerException: null
    at org.fedex.octopoda.repository.RptByCourierSPRepo.callRptByCourierSP(RptByCourierSPRepo.java:66) ~[classes/:na]

spReturn.setPodsCompleted(String.valueOf(spResult.get("PODsCompleted").toString())); <--- line 66

这是我的SQL Server存储过程,如果我像这样运行它在SQL Server中工作

rp_report '2015-01-01','2015-01-02',213

Rp_Report (StartDate, EndDate, Branch)
where
StartDate is datetime
EndDate is datetime
Branch is int

添加了配置

@Configuration
@ComponentScan("org.octopoda")
public class OctopodaConfig {

    @Bean
    public DataSource dataSource() {

        DriverManagerDataSource dataSource = new DriverManagerDataSource();
        dataSource.setDriverClassName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
        dataSource.setUrl("jdbc:sqlserver://localhost:1433;DatabaseName=Test");
        dataSource.setUsername("user");
        dataSource.setPassword("password");

        return dataSource;
    }

    @Bean
    public SimpleJdbcCall simpleJdbc(DataSource datasource) {

        return new SimpleJdbcCall(datasource);
    }

添加了以下行,它现在要求StartDate参数

没有输入
spCall.withCatalogName("dbo");

错误日志2

org.springframework.jdbc.UncategorizedSQLException: CallableStatementCallback; uncategorized SQLException for SQL [{call dbo.rp_report()}]; SQL state [S0004]; error code [201]; Procedure or function 'rp_report' expects parameter '@StartDate', which was not supplied.; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: Procedure or function 'rp_report' expects parameter '@StartDate', which was not supplied.
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:84) ~[spring-jdbc-4.3.2.RELEASE.jar:4.3.2.RELEASE]

0 个答案:

没有答案