ibatis oracle clob

以下是我在项目中的部分代码,仅供参考...

 

 <parameterMap id="replyParameterMap" class="com.bbs.BBSReplyData">
	<parameter property="topicId" javaType="java.lang.String" jdbcType="VARCHAR"  />
	<parameter property="topicTitle" javaType="java.lang.String" jdbcType="VARCHAR"  />
	<parameter property="replyContent" jdbcType="CLOB"	javaType="java.lang.String"  />
	<parameter property="replyerId" javaType="java.lang.String" jdbcType="VARCHAR"  />
	<parameter property="replyerUserName" javaType="java.lang.String" jdbcType="VARCHAR"  />
	<parameter property="replyerTrueName" javaType="java.lang.String" jdbcType="VARCHAR"  />
	<parameter property="typeFlag" javaType="java.lang.String" jdbcType="VARCHAR"  />
	</parameterMap>

 

<insert id="insertReply" parameterMap="replyParameterMap">
		insert into bbs_reply b (
		topicid,
		topic_title,
		reply_content,
		replyer_id,
		replyer_username, 
		replyer_truename,
		type_flag,
		reply_time) values(
		?,?,?,?,?,?,?,sysdate
		)
</insert>

 

import java.util.Date;
/**
 * BBSReplyData entity.
 * 
 * @author Liu Huibin
 */

public class BBSReplyData implements java.io.Serializable {

	// Fields

	private String replyid;
	private BBSTopicData bbsTopicData;
	private String topicId;
	private String topicTitle;
	private String replyerId;
	private String replyerUserName;
	private String replyerTrueName;
	private Date replyTime;
	private String typeFlag;
	private String replyContent;

	// Constructors

	/** default constructor */
	public BBSReplyData() {
	}

	/** minimal constructor */
	public BBSReplyData(String replyid, BBSTopicData bbsTopicData, String replyerId,
			Date replyTime, String replyContent) {
		this.replyid = replyid;
		this.bbsTopicData = bbsTopicData;
		this.replyerId = replyerId;
		this.replyTime = replyTime;
		this.replyContent = replyContent;
	}

	/** full constructor */
	public BBSReplyData(String replyid,String topicId, String topicTitle,
			String replyerId, String replyerUserName,String replyerTrueName, Date replyTime,
			String typeFlag, String replyContent) {
		this.replyid = replyid;
		this.topicId=topicId;
		this.topicTitle = topicTitle;
		this.replyerId = replyerId;
		this.replyerUserName = replyerUserName;
		this.replyerTrueName=replyerTrueName;
		this.replyTime = replyTime;
		this.typeFlag = typeFlag;
		this.replyContent = replyContent;
	}

	// Property accessors

	public String getReplyid() {
		return this.replyid;
	}

	public void setReplyid(String replyid) {
		this.replyid = replyid;
	}

	public BBSTopicData getBbsTopicData() {
		return bbsTopicData;
	}

	public void setBbsTopicData(BBSTopicData bbsTopicData) {
		this.bbsTopicData = bbsTopicData;
	}

	public String getReplyerId() {
		return this.replyerId;
	}

	public void setReplyerId(String replyerId) {
		this.replyerId = replyerId;
	}

	public Date getReplyTime() {
		return this.replyTime;
	}

	public void setReplyTime(Date replyTime) {
		this.replyTime = replyTime;
	}

	public String getTypeFlag() {
		return this.typeFlag;
	}

	public void setTypeFlag(String typeFlag) {
		this.typeFlag = typeFlag;
	}

	public String getReplyContent() {
		return this.replyContent;
	}

	public void setReplyContent(String replyContent) {
		this.replyContent = replyContent;
	}

	public String getReplyerUserName() {
		return replyerUserName;
	}

	public void setReplyerUserName(String replyerUserName) {
		this.replyerUserName = replyerUserName;
	}

	public String getReplyerTrueName() {
		return replyerTrueName;
	}

	public void setReplyerTrueName(String replyerTrueName) {
		this.replyerTrueName = replyerTrueName;
	}
	public String getTopicId() {
		return topicId;
	}

	public void setTopicId(String topicId) {
		this.topicId = topicId;
	}

	public String getTopicTitle() {
		return topicTitle;
	}

	public void setTopicTitle(String topicTitle) {
		this.topicTitle = topicTitle;
	}
}

      一直报错,网上查了很多资料,终于解决,最后使用Oracle 10g的jdbc驱动程序 ,搞定;
另外采用10g 的驱动就算不使用parameterMap也可以成功的插入字符串到CLOB类型字段去,请要注意的是,这样只能插入的字符一定要小于32767个。也就是说我把memo 属性设置多于32766个字符,照样插不进去。这个原因主要是jdbc驱动限制了String的长度的原因。

 

oracle10驱动见附件!

还有解决不了的问题可以Q我:739921140

你可能感兴趣的:(java,oracle,jdbc,ibatis,bbs)