第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

單條信息無法刪除

如下圖所示,單條信息無法刪除,出現(xiàn)下面異常,但是跟著老師的代碼走的,請(qǐng)問是什么原因?

http://img1.sycdn.imooc.com//57dffd410001e0b412430430.jpg

正在回答

4 回答

老師特別提醒,手動(dòng)提交sqlSession.commit()

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

亞努人 提問者

是的!
2016-09-30 回復(fù) 有任何疑惑可以回復(fù)我~

是因?yàn)闆]有手動(dòng)提交事務(wù),即要加入語句:sqlSession.commit();

0 回復(fù) 有任何疑惑可以回復(fù)我~

http://img1.sycdn.imooc.com//57e1353a000124b510820518.jpg

配置文件
<?xml?version="1.0"?encoding="UTF-8"?>
<!DOCTYPE?mapper
????PUBLIC?"-//mybatis.org//DTD?Mapper?3.0//EN"
????"http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper?namespace="Message">

??<resultMap?type="model.Message"?id="MessageResult">
????<id?column="ID"?jdbcType="VARCHAR"?property="id"/>?<!--?id是查找結(jié)果集的主鍵?-->
????<result?column="COMMAND"?jdbcType="VARCHAR"?property="command"/>
????<result?column="DESCRIPTION"?jdbcType="VARCHAR"?property="description"/>
????<result?column="CONTENT"?jdbcType="VARCHAR"?property="content"/>
??</resultMap>

??<select?id="Message.queryAll"?resultMap="MessageResult">
????SELECT?ID,COMMAND,DESCRIPTION,CONTENT?FROM?message?WHERE?1=1
????<if?test="command?!=?null?and?!&quot;&quot;.equals(command.trim())">and?COMMAND?LIKE?'%'?#{command}?'%'</if>
????<if?test="description?!=?null?and?!&quot;&quot;.equals(description.trim())">and?DESCRIPTION?LIKE?'%'?#{description}?'%'</if>
??</select>
??
??<delete?id="deleteOne"?parameterType="java.lang.Integer">
??	DELETE?FROM?message?WHERE?ID=#{_parameter}
??</delete>
</mapper>
DAO層的方法
public?void?deleteOne(int?id){
		DBAccess?dbAccess?=?new?DBAccess();
		SqlSession?sqlSession?=?null;
		try{
			sqlSession?=?dbAccess.getSqlSession();//實(shí)例化并打開數(shù)據(jù)庫會(huì)話
			sqlSession.delete("Message.deleteOne",id);
		}catch(IOException?e){
			e.printStackTrace();
		}finally{
			if(sqlSession!=null){
				sqlSession.close();
			}
		}
	}
Service層的方法
package?service;

import?dao.MessageDAO;

public?class?MaintainService?{
	public?void?deleteOne(String?id){
		if(id?!=?null?&&?!"".equals(id.trim())){
			MessageDAO?messageDao?=?new?MessageDAO();
			messageDao.deleteOne(Integer.valueOf(id));
		}
		
	}

}
Servlet方法
	public?void?doPost(HttpServletRequest?request,?HttpServletResponse?response)
			throws?ServletException,?IOException?{
		request.setCharacterEncoding("utf-8");
		//獲取頁面的值
		String?id?=?request.getParameter("id");
		MaintainService?maintainService?=?new?MaintainService();
		maintainService.deleteOne(id);
		//dao方法和跳轉(zhuǎn)頁面
		try?{
			request.getRequestDispatcher("/servlet/ShowServlet").forward(request,response);
		}?catch?(Exception?e)?{
			e.printStackTrace();
		}
	}
model層的方法
package?model;

public?class?Message?{
	private?int?id;
	private?String?command;
	private?String?description;
	private?String?content;
	public?Message(){}
	
	public?int?getId()?{
		return?id;
	}

	public?void?setId(int?id)?{
		this.id?=?id;
	}

	public?String?getCommand()?{
		return?command;
	}
	public?void?setCommand(String?command)?{
		this.command?=?command;
	}
	public?String?getDescription()?{
		return?description;
	}
	public?void?setDescription(String?description)?{
		this.description?=?description;
	}
	public?String?getContent()?{
		return?content;
	}
	public?void?setContent(String?content)?{
		this.content?=?content;
	}
	
}

麻煩幫忙看下,到底是哪里有問題?

0 回復(fù) 有任何疑惑可以回復(fù)我~

把后面的截圖發(fā)下,還有這個(gè)你mybatis里配置有沒有問題?

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

亞努人 提問者

相關(guān)的截圖和代碼如下所示:
2016-09-20 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

單條信息無法刪除

我要回答 關(guān)注問題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)