将 numeric 转换为数据类型 numeric 时出现算术溢出错误

保存数据时控制台报错:

 1 Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: 将 numeric 转换为数据类型 numeric 时出现算术溢出错误。
 2     at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216)
 3     at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1515)
 4     at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:404)
 5     at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:350)
 6     at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696)
 7     at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715)
 8     at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:180)
 9     at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:155)
10     at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate(SQLServerPreparedStatement.java:314)
11     at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_executeUpdate(FilterChainImpl.java:2717)
12     at com.alibaba.druid.filter.FilterAdapter.preparedStatement_executeUpdate(FilterAdapter.java:1052)
13     at com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_executeUpdate(FilterEventAdapter.java:491)
14     at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_executeUpdate(FilterChainImpl.java:2715)
15     at com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl.executeUpdate(PreparedStatementProxyImpl.java:106)
16     at com.alibaba.druid.pool.DruidPooledPreparedStatement.executeUpdate(DruidPooledPreparedStatement.java:237)
17     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
18     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
19     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
20     at java.lang.reflect.Method.invoke(Method.java:498)
21     at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:122)
22     ... 91 more
View Code

数据库长度比例(SqlServer字段长度和比例指什么意思?)

NUMERIC(P,S) P的默认值是:38 S的默认值是:-84~127
numeric(a,b)函数有两个参数,前面一个为总的位数,后面一个参数是小数点后的位数,例如numeric(5,2)是总位数为5,小数点后为2位的数,也就是说这个字段的整数位最大是3位。

前台传来的参数为格式不对

添加前台文本框进行校验:

1 onkeyup= "if( !/^(((\d|[1-9]\d|[1-9]\d[1-8])(\.\d+)?)|(999(\.\d{1,2})?))$/.test(this.value)){
2                            alertTip('不得超过1000,保留小数点后2位');
3                            this.value='';
4                        }"
View Code

后台接收参数后也要校验(略)

 

posted @ 2018-08-27 18:30  习惯沉淀  阅读(12297)  评论(0编辑  收藏  举报