ibatis错误求解
本人初学者。求指教SqlMapConfig.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMapConfig
PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<properties resource="SqlMap.properties"/>
<transactionManager type="JDBC" commitRequired="false">
<dataSource type="SIMPLE">
<property name="JDBC.Driver" value="${driver}"/>
<property name="JDBC.ConnectionURL" value="${url}"/>
<property name="JDBC.Username" value="${username}"/>
<property name="JDBC.Password" value="${password}"/>
</dataSource>
</transactionManager>
<sqlMap resource="com/yxtx/userbean/User.xml"/>
</sqlMapConfig>
映射文件 user.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMap
PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap>
<typeAlias alias="User" type="com.yxtx.userbean.User"/>
<resultMap class="User" id="UserResult">
<result column="id" property="id" jdbcType="INT" />
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="weight" property="weight" jdbcType="VARCHAR"/>
<result column="height" property="height" jdbcType="VARCHAR"/>
<result column="hobby" property="hobby" jdbcType="VARCHAR"/>
</resultMap>
<insert id="addUser" parameterClass="User">
insert into I_user(
id,name,weight,height,hobby
)
values(
#id#,#name#,#weight#,#height#,#hobby#)
</insert>
</sqlMap>
在保证输入正确的情况下 为什么会出现以下的错误:
com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in com/yxtx/userbean/User.xml.
--- The error occurred while applying a parameter map.
--- Check the addUser-InlineParameterMap.
--- Check the parameter mapping for the 'height' property.
--- Cause: java.lang.NullPointerException
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:94)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.insert(SqlMapExecutorDelegate.java:447)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.insert(SqlMapSessionImpl.java:82)
at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.insert(SqlMapClientImpl.java:59)
at com.yxtx.DAO.UserDAOImpl.addUser(UserDAOImpl.java:29)
at com.yxtx.servlet.UserServlet.addUser(UserServlet.java:130)
at com.yxtx.servlet.UserServlet.doPost(UserServlet.java:74)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NullPointerException
at com.microsoft.sqlserver.jdbc.AppDTVImpl$SetValueOp.executeDefault(Unknown Source)
at com.microsoft.sqlserver.jdbc.DTV.executeOp(Unknown Source)
at com.microsoft.sqlserver.jdbc.AppDTVImpl.setValue(Unknown Source)
at com.microsoft.sqlserver.jdbc.DTV.setValue(Unknown Source)
at com.microsoft.sqlserver.jdbc.Parameter.setValue(Unknown Source)
at com.microsoft.sqlserver.jdbc.Parameter.setValue(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.setNull(Unknown Source)
at com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap.setParameter(BasicParameterMap.java:171)
at com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap.setParameters(BasicParameterMap.java:125)
at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeUpdate(SqlExecutor.java:79)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteUpdate(GeneralStatement.java:200)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:78)
... 20 more
。
我又把 插入语距离的 height删掉 。。他还提示这个错误 。。只不过里面的height换成了 hobby 。我又把hobby删掉。。然后执行却成功插入数据。。
为什么这是为什么????求高手指点
--------------------编程问答-------------------- 你的数据库字段名是height和hobby么 --------------------编程问答-------------------- 第一、检查你数据库的字段名是否是height和hobby
第二、检查com.yxtx.userbean.User类的属性名是否是height和hobby --------------------编程问答-------------------- 我也很想知道这个问题,麻烦有没有易做图指点一下啊 --------------------编程问答-------------------- 第一、检查你数据库的字段名是否是height和hobby
第二、检查com.yxtx.userbean.User类的属性名是否是height和hobby、
严重同意
补充:Java , Java EE