NutzCN Logo
问答 调用sqlServer存储过程报错,不知道出参怎么设置
发布于 18天前 作者 qq_7fafbecc 127 次浏览 复制 上一个帖子 下一个帖子
标签:

java代码:

Sql sql = Sqls.create("CALL sp_SyncDictDiagnosis(@OUT@insertNum, @OUT@updateNum)");
	    sql.setEntity(dao.getEntity(Record.class));
	    sql.params().set("OUT@insertNum", Types.INTEGER);
	    sql.params().set("OUT@updateNum", Types.INTEGER);// 设置出参类型,注意,必须加OUT开头
	    dao.execute(sql);

	    Record re = sql.getOutParams();

后台报错日志:

2018-05-31 17:27:15,464 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - CALL sp_SyncDictDiagnosis(??, ??)
    |    1 |    2 |    3 |    4 |
    |------|------|------|------|
    | NULL | NULL | NULL | NULL |
  For example:> "CALL sp_SyncDictDiagnosis('NULL''NULL', 'NULL''NULL')"
2018-05-31 17:27:15,464 org.nutz.dao.impl.sql.run.NutDaoExecutor._runExec(NutDaoExecutor.java:118) DEBUG - CALL sp_SyncDictDiagnosis(??, ??)
2018-05-31 17:27:18,158 com.shlx.blood.service.ComServices.ExcuteServices(ComServices.java:143) DEBUG - Fail to invoke [com.shlx.blood.service.dict.PublicDictService$$NUTZAOP].syncDictDiagnosis() by args:
 {}
For the reason: 同步数据时出错:java.lang.NullPointerException
org.nutz.lang.InvokingException: Fail to invoke [com.shlx.blood.service.dict.PublicDictService$$NUTZAOP].syncDictDiagnosis() by args:
 {}
For the reason: 同步数据时出错:java.lang.NullPointerException
	at org.nutz.lang.Invoking.invoke(Invoking.java:195)
	at org.nutz.lang.Mirror.invoke(Mirror.java:1100)
	at com.shlx.blood.service.ComServices.ExcuteServices(ComServices.java:140)
	at com.shlx.blood.action.dict.PublicDictAction.syncDictDiagnosis(PublicDictAction.java:250)
	at com.shlx.blood.action.dict.PublicDictAction$$FASTCLASS._invoke(PublicDictAction.java:1)
	at org.nutz.lang.reflect.AbstractFastClass.invoke(AbstractFastClass.java:143)
	at org.nutz.lang.reflect.FastClassFactory.invoke(FastClassFactory.java:67)
	at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:27)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:33)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:58)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at com.shlx.blood.mvc.SessionCheckProcessor.process(SessionCheckProcessor.java:56)
	at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
	at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
	at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
	at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:198)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1434)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Unknown Source)
Caused by: com.shlx.blood.exception.BusinessException: 同步数据时出错:java.lang.NullPointerException
	at com.shlx.blood.service.dict.PublicDictService.syncDictDiagnosis(PublicDictService.java:566)
	at com.shlx.blood.service.dict.PublicDictService$$NUTZAOP._aop_invoke(PublicDictService.java:10)
	at org.nutz.aop.InterceptorChain.invoke(InterceptorChain.java:77)
	at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:57)
	at org.nutz.aop.interceptor.TransactionInterceptor.filter(TransactionInterceptor.java:34)
	at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:60)
	at com.shlx.blood.aop.ServiceInterceptor.filter(ServiceInterceptor.java:48)
	at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:60)
	at com.shlx.blood.service.dict.PublicDictService$$NUTZAOP.syncDictDiagnosis(PublicDictService.java:1)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.nutz.lang.Invoking$DefaultInvoker.invoke(Invoking.java:47)
	at org.nutz.lang.Invoking.invoke(Invoking.java:192)
	... 42 more

17 回复

先搞清楚什么东西是null

@OUT@insertNum 是什么东西,中间的@去掉

USE [xxxxx]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- =============================================
ALTER PROCEDURE [dbo].[sp_SyncDictDiagnosis]
(
	@insertNum INT OUTPUT,
	@updateNum INT OUTPUT
) 
AS
BEGIN
	--declare @insertNum int;
	--declare @updateNum int;
	set @insertNum = 0;
	set @updateNum = 0;
	--第一步:先找出两边都有的记录
	declare d_cursor cursor for select 

@insertNum是存储过程的出参

去掉中间的@

然后试试

int insertNum = 0;
		int updateNum = 0;

		Sql sql = Sqls.create("CALL sp_SyncDictDiagnosis(@OUTinsertNum, @OUTupdateNum)");
	    sql.setEntity(dao.getEntity(Record.class));
	    sql.params().set("OUT@insertNum", Types.INTEGER);
	    sql.params().set("OUT@updateNum", Types.INTEGER);// 设置出参类型,注意,必须加OUT开头
	    dao.execute(sql);

	    Record re = sql.getOutParams();

错误日志

2018-05-31 17:42:09,933 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - CALL sp_SyncDictDiagnosis(?, ?)
    |    1 |    2 |
    |------|------|
    | NULL | NULL |
  For example:> "CALL sp_SyncDictDiagnosis('NULL', 'NULL')"
2018-05-31 17:42:09,949 org.nutz.dao.impl.sql.run.NutDaoExecutor._runExec(NutDaoExecutor.java:118) DEBUG - CALL sp_SyncDictDiagnosis(?, ?)
2018-05-31 17:42:13,749 com.shlx.blood.service.ComServices.ExcuteServices(ComServices.java:143) DEBUG - Fail to invoke [com.shlx.blood.service.dict.PublicDictService$$NUTZAOP].syncDictDiagnosis() by args:
 {}
For the reason: 同步数据时出错:java.lang.NullPointerException
org.nutz.lang.InvokingException: Fail to invoke [com.shlx.blood.service.dict.PublicDictService$$NUTZAOP].syncDictDiagnosis() by args:
 {}
For the reason: 同步数据时出错:java.lang.NullPointerException
	at org.nutz.lang.Invoking.invoke(Invoking.java:195)
	at org.nutz.lang.Mirror.invoke(Mirror.java:1100)
	at com.shlx.blood.service.ComServices.ExcuteServices(ComServices.java:140)
	at com.shlx.blood.action.dict.PublicDictAction.syncDictDiagnosis(PublicDictAction.java:250)
	at com.shlx.blood.action.dict.PublicDictAction$$FASTCLASS._invoke(PublicDictAction.java:1)
	at org.nutz.lang.reflect.AbstractFastClass.invoke(AbstractFastClass.java:143)
	at org.nutz.lang.reflect.FastClassFactory.invoke(FastClassFactory.java:67)
	at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:27)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:33)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:58)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at com.shlx.blood.mvc.SessionCheckProcessor.process(SessionCheckProcessor.java:56)
	at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
	at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
	at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
	at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:198)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1434)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Unknown Source)
Caused by: com.shlx.blood.exception.BusinessException: 同步数据时出错:java.lang.NullPointerException
	at com.shlx.blood.service.dict.PublicDictService.syncDictDiagnosis(PublicDictService.java:566)
	at com.shlx.blood.service.dict.PublicDictService$$NUTZAOP._aop_invoke(PublicDictService.java:10)
	at org.nutz.aop.InterceptorChain.invoke(InterceptorChain.java:77)
	at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:57)
	at org.nutz.aop.interceptor.TransactionInterceptor.filter(TransactionInterceptor.java:34)
	at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:60)
	at com.shlx.blood.aop.ServiceInterceptor.filter(ServiceInterceptor.java:48)
	at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:60)
	at com.shlx.blood.service.dict.PublicDictService$$NUTZAOP.syncDictDiagnosis(PublicDictService.java:1)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.nutz.lang.Invoking$DefaultInvoker.invoke(Invoking.java:47)
	at org.nutz.lang.Invoking.invoke(Invoking.java:192)
	... 42 more

PublicDictService.java:566 是哪一行代码

代码:

int insertNum = 0;
		int updateNum = 0;

		Sql sql = Sqls.create("CALL sp_SyncDictDiagnosis(@OUTinsertNum, @OUTupdateNum)");
	    sql.setEntity(dao.getEntity(Record.class));
	    sql.params().set("OUTinsertNum", Types.INTEGER);
	    sql.params().set("OUTupdateNum", Types.INTEGER);// 设置出参类型,注意,必须加OUT开头
	    dao.execute(sql);

	    Record re = sql.getOutParams();

日志

2018-05-31 17:44:27,717 org.nutz.dao.impl.entity.AnnotationEntityMaker.make(AnnotationEntityMaker.java:116) WARN  - No @Table found, fallback to use table name='record' for type 'org.nutz.dao.entity.Record'
2018-05-31 17:44:27,725 org.nutz.dao.jdbc.Jdbcs.guessEntityFieldColumnType(Jdbcs.java:863) DEBUG - take field 'map(java.util.Map)'(org.nutz.dao.entity.Record) as VARCHAR(128)
2018-05-31 17:44:27,725 org.nutz.dao.jdbc.Jdbcs.guessEntityFieldColumnType(Jdbcs.java:863) DEBUG - take field 'keys(java.util.List)'(org.nutz.dao.entity.Record) as VARCHAR(128)
2018-05-31 17:44:27,772 org.nutz.dao.impl.jdbc.AbstractJdbcExpert.setupEntityField(AbstractJdbcExpert.java:108) DEBUG - Table 'record' doesn't exist!
2018-05-31 17:44:29,812 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - CALL sp_SyncDictDiagnosis(?, ?)
    | 1 | 2 |
    |---|---|
    | 4 | 4 |
  For example:> "CALL sp_SyncDictDiagnosis(4, 4)"
2018-05-31 17:44:29,812 org.nutz.dao.impl.sql.run.NutDaoExecutor._runExec(NutDaoExecutor.java:118) DEBUG - CALL sp_SyncDictDiagnosis(?, ?)
2018-05-31 17:44:29,835 org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:97) DEBUG - SQLException
com.microsoft.sqlserver.jdbc.SQLServerException: '@P0' 附近有语法错误。
	at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:197)
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1493)
	at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:390)
	at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:340)
	at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:4874)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1400)
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:179)
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:154)
	at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.execute(SQLServerPreparedStatement.java:322)
	at com.alibaba.druid.pool.DruidPooledPreparedStatement.execute(DruidPooledPreparedStatement.java:493)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor._runExec(NutDaoExecutor.java:152)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:68)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:66)
	at org.nutz.dao.impl.interceptor.DaoLogInterceptor.filter(DaoLogInterceptor.java:22)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:64)
	at org.nutz.dao.DaoInterceptorChain.invoke(DaoInterceptorChain.java:139)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.runCallback(NutDaoRunner.java:158)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithTransaction(NutDaoRunner.java:104)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._run(NutDaoRunner.java:88)
	at org.nutz.dao.impl.sql.run.NutDaoRunner$1.run(NutDaoRunner.java:74)
	at org.nutz.trans.Trans.exec(Trans.java:174)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:72)
	at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:240)
	at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:248)
	at org.nutz.dao.impl.DaoSupport.execute(DaoSupport.java:236)
	at org.nutz.dao.impl.NutDao.execute(NutDao.java:973)
	at com.shlx.blood.service.bo.DictPublicServiceBo.syncDictDiagnosis(DictPublicServiceBo.java:1187)
	at com.shlx.blood.service.dict.PublicDictService.syncDictDiagnosis(PublicDictService.java:564)
	at com.shlx.blood.service.dict.PublicDictService$$NUTZAOP._aop_invoke(PublicDictService.java:6)
	at org.nutz.aop.InterceptorChain.invoke(InterceptorChain.java:77)
	at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:57)
	at org.nutz.aop.interceptor.TransactionInterceptor.filter(TransactionInterceptor.java:34)
	at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:60)
	at com.shlx.blood.aop.ServiceInterceptor.filter(ServiceInterceptor.java:48)
	at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:60)
	at com.shlx.blood.service.dict.PublicDictService$$NUTZAOP.syncDictDiagnosis(PublicDictService.java:1)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.nutz.lang.Invoking$DefaultInvoker.invoke(Invoking.java:47)
	at org.nutz.lang.Invoking.invoke(Invoking.java:192)
	at org.nutz.lang.Mirror.invoke(Mirror.java:1100)
	at com.shlx.blood.service.ComServices.ExcuteServices(ComServices.java:140)
	at com.shlx.blood.action.dict.PublicDictAction.syncDictDiagnosis(PublicDictAction.java:250)
	at com.shlx.blood.action.dict.PublicDictAction$$FASTCLASS._invoke(PublicDictAction.java:1)
	at org.nutz.lang.reflect.AbstractFastClass.invoke(AbstractFastClass.java:143)
	at org.nutz.lang.reflect.FastClassFactory.invoke(FastClassFactory.java:67)
	at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:27)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:33)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:58)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at com.shlx.blood.mvc.SessionCheckProcessor.process(SessionCheckProcessor.java:56)
	at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
	at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
	at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
	at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:198)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1434)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Unknown Source)
2018-05-31 17:44:32,154 com.shlx.blood.service.ComServices.ExcuteServices(ComServices.java:143) DEBUG - Fail to invoke [com.shlx.blood.service.dict.PublicDictService$$NUTZAOP].syncDictDiagnosis() by args:
 {}
For the reason: 同步数据时出错:!Nutz SQL Error: 'CALL sp_SyncDictDiagnosis(4, 4)'
PreparedStatement: 
'CALL sp_SyncDictDiagnosis(?, ?)'
CaseMessage='@P0' 附近有语法错误。
org.nutz.lang.InvokingException: Fail to invoke [com.shlx.blood.service.dict.PublicDictService$$NUTZAOP].syncDictDiagnosis() by args:
 {}
For the reason: 同步数据时出错:!Nutz SQL Error: 'CALL sp_SyncDictDiagnosis(4, 4)'
PreparedStatement: 
'CALL sp_SyncDictDiagnosis(?, ?)'
CaseMessage='@P0' 附近有语法错误。
	at org.nutz.lang.Invoking.invoke(Invoking.java:195)
	at org.nutz.lang.Mirror.invoke(Mirror.java:1100)
	at com.shlx.blood.service.ComServices.ExcuteServices(ComServices.java:140)
	at com.shlx.blood.action.dict.PublicDictAction.syncDictDiagnosis(PublicDictAction.java:250)
	at com.shlx.blood.action.dict.PublicDictAction$$FASTCLASS._invoke(PublicDictAction.java:1)
	at org.nutz.lang.reflect.AbstractFastClass.invoke(AbstractFastClass.java:143)
	at org.nutz.lang.reflect.FastClassFactory.invoke(FastClassFactory.java:67)
	at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:27)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:33)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:58)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at com.shlx.blood.mvc.SessionCheckProcessor.process(SessionCheckProcessor.java:56)
	at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
	at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
	at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
	at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:198)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1434)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Unknown Source)
Caused by: com.shlx.blood.exception.BusinessException: 同步数据时出错:!Nutz SQL Error: 'CALL sp_SyncDictDiagnosis(4, 4)'
PreparedStatement: 
'CALL sp_SyncDictDiagnosis(?, ?)'
CaseMessage='@P0' 附近有语法错误。
	at com.shlx.blood.service.dict.PublicDictService.syncDictDiagnosis(PublicDictService.java:566)
	at com.shlx.blood.service.dict.PublicDictService$$NUTZAOP._aop_invoke(PublicDictService.java:6)
	at org.nutz.aop.InterceptorChain.invoke(InterceptorChain.java:77)
	at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:57)
	at org.nutz.aop.interceptor.TransactionInterceptor.filter(TransactionInterceptor.java:34)
	at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:60)
	at com.shlx.blood.aop.ServiceInterceptor.filter(ServiceInterceptor.java:48)
	at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:60)
	at com.shlx.blood.service.dict.PublicDictService$$NUTZAOP.syncDictDiagnosis(PublicDictService.java:1)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.nutz.lang.Invoking$DefaultInvoker.invoke(Invoking.java:47)
	at org.nutz.lang.Invoking.invoke(Invoking.java:192)
	... 42 more

	@ServiceLog
	@Aop(TransAop.READ_COMMITTED)
	public Object syncDictDiagnosis(NutMap map) throws BusinessException {
		NutMap resultMap = new NutMap();
		try{
			resultMap = dictPublicServiceBo.syncDictDiagnosis();
		}catch(Exception e){
			throw new BusinessException("同步数据时出错:"+e.getMessage());
		}
		return resultMap;
	}

566: throw new BusinessException("同步数据时出错:"+e.getMessage());

报错信息不一样了

sql.params().set("OUT@insertNum", Types.INTEGER);
sql.params().set("OUT@updateNum", Types.INTEGER);// 设置出参类型,注意,必须加OUT开头

sql.params().set("OUTinsertNum", Types.INTEGER);
sql.params().set("OUTupdateNum", Types.INTEGER);// 设置出参类型,注意,必须加OUT开头

前两行是错误的

可是我存储过程中的出参变量就是带了@符号的
@insertNum

设置和取的时候不需要@吧,sqlserver不一样的?

现在SqlServer的出参,必须带@符号,那么这个问题,是不是无法解决呢?
如果无法解决,我就考虑,不带出参了

取的时候不需要带啊, 是写存储过程的时候带吧?

只写

sql.params().set("OUTinsertNum", Types.INTEGER);
sql.params().set("OUTupdateNum", Types.INTEGER);// 设置出参类型,注意,必须加OUT开头

看看报啥嘛

添加回复
请先登陆
回到顶部