6
回答
ibatis中xml问题。
滴滴云服务器,限时包月0.9元,为开发者而生>>>   

提示错误:
javax.servlet.ServletException: org.springframework.jdbc.BadSqlGrammarException: SqlMapClient operation; bad SQL grammar []; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:  
--- The error occurred in com/product/user/Users.hbm.xml. 
--- The error occurred while applying a parameter map. 
--- Check the updateUsers-InlineParameterMap. 
--- Check the statement (update failed). 
--- Cause: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where UserId=2' at line 1 org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:515)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419)
com.product.servlet.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:36)


root cause

好像是更新已有信息那一段有语法错误,但是感觉没错啊。。找了好久 求指点
我是要实现从页面中输入数据,来更新数据库信息
下面是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 namespace="Users">

  <typeAlias alias="users" type="com.product.user.Users"/>
  

  
  <select id="getUserByAccount" resultClass="users" parameterClass="java.lang.String">
    SELECT
      UserId,
      UserName,
      Account,
      Password
    FROM Users where Account=#account#
  </select>
  
  <!-- 获取所有用户信息 -->
   <select id="getUsersList" resultClass="users" >
    SELECT
      UserId,
      UserName,
      Account,
      password
    FROM Users order by UserId desc
  </select>
  
  <!-- 更新已有信息 -->
  <update id="updateUsers" parameterClass="Users">
  update Users
      set
      UserName=#userName#,
      Account=#account#,
      password=#password#
    where UserId=#userId#
  </update>
  
  <!--修改个人信息-->
  <insert id="insertUsers" parameterClass="Users">
    <!-- insert into Users
     (UserName,Account,password,UserId)
     values
     (#userName#,#accout#,#password#,#userId#);-->
  </insert>

</sqlMap>

举报
YYxlid
发帖于5年前 6回/897阅
顶部