Servlet.service() for servlet [springMVC] in context with path [/project_manager] threw exception [R
来源:互联网 发布:mac搜索移动硬盘文件 编辑:程序博客网 时间:2024/05/18 12:33
javaweb项目使用SQLserver+mybatis这是我写的添加一条记录出现的问题
Servlet.service() for servlet [springMVC] in context with path [/project_manager] threw exception [Request processing failed; nested exception is org.springframework.jdbc.UncategorizedSQLException: Error selecting key or setting result to parameter object. Cause: com.microsoft.sqlserver.jdbc.SQLServerException: 'IFNULL' is not a recognized built-in function name.
; uncategorized SQLException for SQL []; SQL state [S00010]; error code [195]; 'IFNULL' is not a recognized built-in function name.; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: 'IFNULL' is not a recognized built-in function name.] with root cause
com.microsoft.sqlserver.jdbc.SQLServerException: 'IFNULL' is not a recognized built-in function name.
找了半天发现是.xml文件出现的问题。
先看一下代码:
<sql id="getPk"> //为了找到添加的下一条记录的主键值 SELECT IFNULL(MAX(${pk}),0)+1 FROM ${tb}</sql>
<insert id="addDevType" parameterType="com.electric.beans.DevTypeInfo"> <selectKey keyProperty="type_id" order="BEFORE" resultType="int"> <include refid="getPk"> <property name="pk" value="type_id"></property> <property name="tb" value="devTypeInfo"></property> </include> </selectKey> insert into devTypeInfo values(#{type_id},#{type_name},#{isUsed},#{dev_selfName})</insert>因为之前一直使用的是mysql数据库没毛病,所以直接粘过来。结果发现出了上面所说的问题。
之后把上面的那条语句粘到
SELECT IFNULL(MAX(${pk}),0)+1 FROM ${tb}
SQLserver manager studio并选择一个合适的表和主键代替,并运行,结果说是1.IFNULL不是内置函数
2.max内置函数只有一个参数
所以我认识到这是因为数据库的内置函数的不同,这也是出现这个问题的根本原因。所以我查看了一下SQLserver的内置函数,重新写了一下
新的正确的
<sql id="getPk"> select ISNull(max(${pk}),0)+1 from ${tb}</sql>
之后运行正确,问题解决。
我的收获:任何事情找其相同点是很方便,但是切莫忽略其不同之处。有时问题就出现在这些不同之处。总而言之需要认真去做。
- Servlet.service() for servlet [springMVC] in context with path [/project_manager] threw exception [R
- Servlet.service() for servlet [springmvc] in context with path [] threw exception [Request processin
- Servlet.service() for servlet [springMVC] in context with path [] threw exception [Could not get Req
- 报错Servlet.service() for servlet [SpringMVC] in context with path [/cms] threw exception 问题及解决方法
- 严重: Servlet.service() for servlet [default] in context with path [/a] threw exception [edu.yale.its.
- 严重: Servlet.service() for servlet [jsp] in context with path [] threw exception [/addGoods.jsp(1,34)
- Servlet.service() for servlet [userServlet] in context with path [/rbps7] threw exception
- 严重: Servlet.service() for servlet [default] in context with path [/aaa] threw exception
- 严重: Servlet.service() for servlet [default] in context with path [/aaa] threw exception
- Servlet.service() for servlet [spring] in context with path [] threw exception [Request processing f
- 严重: Servlet.service() for servlet [spring] in context with path [/XX] threw exception [Request
- Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Filter ex
- Servlet.service() for servlet [springServlet] in context with path [/TESTVIDEO] threw exception [Req
- Servlet.service() for servlet [jsp] in context with path [/Kindergarten] threw exception [Unable to
- Tomcat+Eclipse+Ubuntu ××× Servlet.service() for servlet [jsp] in context with path [] threw exceptio
- Servlet.service() for servlet [spring] in context with path [/]
- Servlet.service() for servlet jsp threw exception
- Servlet.service() for servlet default threw exception
- Python基础知识点
- Kotlin开发安卓APP笔记-类和对象(2)
- [分享]钛极OS(TiJOS)之电源管理
- java自学笔记(第三天)
- http 和 https 有何区别?
- Servlet.service() for servlet [springMVC] in context with path [/project_manager] threw exception [R
- replaceAll时遇到的$转义问题
- selenium示例
- Error:A problem was found with the configuration of task ':app:packageDebug' 问题解决
- excel自定义公式提取汉字
- Android 仿京东删除购物车代码(自用,有问题)
- 找到你的关闭开关:恢复平衡的九条贴士
- 最全Tortoise SVN Clean up失败的解决方法合集
- RHEL 7 防火墙