springframework.jdbc在JdbcTemplate执行调用存储过程后更改值

时间:2013-09-19 15:42:32

标签: java spring sql-server-2008 tsql spring-jdbc

我一直在使用springframework.jdbc库来尝试从我的webproject中的数据库中检索数据。由于某种原因,跟踪中的这一行:

TRACE: org.springframework.jdbc.core.StatementCreatorUtils - Setting SQL statement parameter value: column index 15, parameter value [0.005], value class [java.math.BigDecimal], SQL type 2

似乎要转换发送到类的值:0.005到5当我在我的sql server探查器中捕获它时。正如跟踪所说,发送给类的值是java.math.BigDecimal类型,然后我在其他单词java.sql.Types.NUMERIC中使用SQL类型2,如下图所示:

declareParameter(new SqlParameter("Deviation", Types.NUMERIC));

我怀疑发生的是javalayer中的内容,或者hibernate只发送BigDecimal值的BigInteger部分。我如何解决这个问题,解决问题? 任何建议都大大适用。我还在log4j可以跟踪的最热门级别以及SQL服务器分析器捕获的内容中完整地记录了java中发生的事情。

java中的跟踪:

DEBUG: org.springframework.jdbc.core.JdbcTemplate - Calling stored procedure [{call sp_MyProcedure(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)}]
DEBUG: org.springframework.jdbc.datasource.DataSourceUtils - Fetching JDBC Connection from DataSource
TRACE: org.springframework.jdbc.core.StatementCreatorUtils - Setting SQL statement parameter value: column index 1, parameter value [null], value class [null], SQL type -7
TRACE: org.springframework.jdbc.core.StatementCreatorUtils - Setting SQL statement parameter value: column index 2, parameter value [null], value class [null], SQL type 4
TRACE: org.springframework.jdbc.core.StatementCreatorUtils - Setting SQL statement parameter value: column index 3, parameter value [null], value class [null], SQL type 4
TRACE: org.springframework.jdbc.core.StatementCreatorUtils - Setting SQL statement parameter value: column index 4, parameter value [329689], value class [java.lang.Integer], SQL type 4
TRACE: org.springframework.jdbc.core.StatementCreatorUtils - Setting SQL statement parameter value: column index 5, parameter value [1], value class [java.lang.Integer], SQL type 4
TRACE: org.springframework.jdbc.core.StatementCreatorUtils - Setting SQL statement parameter value: column index 6, parameter value [null], value class [null], SQL type 4
TRACE: org.springframework.jdbc.core.StatementCreatorUtils - Setting SQL statement parameter value: column index 7, parameter value [null], value class [null], SQL type 4
TRACE: org.springframework.jdbc.core.StatementCreatorUtils - Setting SQL statement parameter value: column index 8, parameter value [2013-09-18], value class [java.lang.String], SQL type 91
TRACE: org.springframework.jdbc.core.StatementCreatorUtils - Setting SQL statement parameter value: column index 9, parameter value [2013-09-19], value class [java.lang.String], SQL type 91
TRACE: org.springframework.jdbc.core.StatementCreatorUtils - Setting SQL statement parameter value: column index 10, parameter value [null], value class [null], SQL type 91
TRACE: org.springframework.jdbc.core.StatementCreatorUtils - Setting SQL statement parameter value: column index 11, parameter value [null], value class [null], SQL type 91
TRACE: org.springframework.jdbc.core.StatementCreatorUtils - Setting SQL statement parameter value: column index 12, parameter value [false], value class [java.lang.Boolean], SQL type -7
TRACE: org.springframework.jdbc.core.StatementCreatorUtils - Setting SQL statement parameter value: column index 13, parameter value [false], value class [java.lang.Boolean], SQL type -7
TRACE: org.springframework.jdbc.core.StatementCreatorUtils - Setting SQL statement parameter value: column index 14, parameter value [false], value class [java.lang.Boolean], SQL type -7
<--Value that becomes converted bellow-->
TRACE: org.springframework.jdbc.core.StatementCreatorUtils - Setting SQL statement parameter value: column index 15, parameter value [0.005], value class [java.math.BigDecimal], SQL type 2
TRACE: org.springframework.jdbc.core.StatementCreatorUtils - Setting SQL statement parameter value: column index 16, parameter value [null], value class [null], SQL type 4
TRACE: org.springframework.jdbc.core.StatementCreatorUtils - Setting SQL statement parameter value: column index 17, parameter value [true], value class [java.lang.Boolean], SQL type -7
DEBUG: org.springframework.jdbc.core.JdbcTemplate - CallableStatement.execute() returned 'true'
DEBUG: org.springframework.jdbc.core.JdbcTemplate - CallableStatement.getUpdateCount() returned -1
DEBUG: org.springframework.jdbc.core.JdbcTemplate - CallableStatement.getUpdateCount() returned -1
DEBUG: org.springframework.jdbc.core.JdbcTemplate - SQLWarning ignored: SQL state 'S0001', error code '0', message [20130919: 2]
DEBUG: org.springframework.jdbc.datasource.DataSourceUtils - Returning JDBC Connection to DataSource

SQL Server Profiler中的跟踪:

declare @p1 int
set @p1=8
exec sp_prepexec @p1 output,N'@P0 bit,@P1 int,@P2 int,@P3 int,@P4 int,@P5 int,@P6 int,@P7 date,@P8 date,@P9 date,@P10 date,@P11 bit,@P12 bit,@P13 bit,@P14 decimal(38,3),@P15 int,@P16 bit',N'EXEC sp_MyProcedure @P0, @P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9, @P10, @P11, @P12, @P13, @P14, @P15, @P16                                                                                                                                 ',NULL,NULL,NULL,NULL,1,NULL,NULL,N'2013-09-18',N'2013-09-19',NULL,NULL,0,0,0,5,NULL,1
select @p1

0 个答案:

没有答案