是的,每次调用那个类都有问题,这是我的SqlMapConfig配置文件代码
<?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="cn/dao/SqlMap.properties" />
<transactionManager type="JDBC">
<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="cn/dao/Stuinfo.xml"/>
</sqlMapConfig>
这是实体类的代码
package cn.student;import org.apache.struts.action.ActionForm;public class AddStuinfoForm extends ActionForm {
private String name;
private Integer id;
private String address;
private String sex;
public AddStuinfoForm(){
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
}这是实体类对应的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="stu" type="cn.student.AddStuinfoForm"/>
<select id="selectAllStu" resultClass="stu">
select name,address,id,sex from stuinfo
</select>
<update id="UpdateStu" parameterClass="stu">
<![CDATA[update stuinfo set name=#name#,id=#id#,address=#address#,sex=#sex#]]>
</update>
<insert id="InsertStu" parameterClass="stu">
insert into stuinfo (name,id,address,sex) values(#name#,#id#,#address#,#sex#)
</insert>
<delete id="deleteStu" parameterClass="java.Lang.Integer">
delete from stuinfo where id=#id#
</delete>
</sqlMap>
struts部分应该没问题,我用JDBC代替IBATIS就能正常运行。
<?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="cn/dao/SqlMap.properties" />
<transactionManager type="JDBC">
<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="cn/dao/Stuinfo.xml"/>
</sqlMapConfig>
这是实体类的代码
package cn.student;import org.apache.struts.action.ActionForm;public class AddStuinfoForm extends ActionForm {
private String name;
private Integer id;
private String address;
private String sex;
public AddStuinfoForm(){
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
}这是实体类对应的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="stu" type="cn.student.AddStuinfoForm"/>
<select id="selectAllStu" resultClass="stu">
select name,address,id,sex from stuinfo
</select>
<update id="UpdateStu" parameterClass="stu">
<![CDATA[update stuinfo set name=#name#,id=#id#,address=#address#,sex=#sex#]]>
</update>
<insert id="InsertStu" parameterClass="stu">
insert into stuinfo (name,id,address,sex) values(#name#,#id#,#address#,#sex#)
</insert>
<delete id="deleteStu" parameterClass="java.Lang.Integer">
delete from stuinfo where id=#id#
</delete>
</sqlMap>
struts部分应该没问题,我用JDBC代替IBATIS就能正常运行。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货