马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
请问各位大佬为啥会出现图片中的报错
这是测试类的代码import java.io.IOException;
import java.io.Reader;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import com.oracle.po.Student;
public class Test {
public static void main(String[] age) {
Student s=new Student();
s.setStudent_age(20);
s.setStudent_email("123@qq.com");
s.setStudent_id(123456);
s.setStudent_name("张三");
try {
//将主配置文件的内容读到一个 io。Reader中
Reader reader= Resources.getResourceAsReader("configuration.xml");
//使用mybatis的一个核心接口 SqlSessionFactory是SqlSession的工厂,生产SqlSession
SqlSessionFactory factory=new SqlSessionFactoryBuilder().build(reader);
//创建SqlSession对象 使用mybatis的SqlSession核心接口
SqlSession sqlsession= factory.openSession();
//调用sqlsession的insert方法执行SQL语句
sqlsession.insert("Student.insert",s);
sqlsession.commit();
} catch (IOException es) {
// TODO Auto-generated catch block
es.printStackTrace();
}
}
}
这是学生类的package com.oracle.po;
public class Student {
private int student_id;
private String student_name;
private String student_email;
private int student_age;
public int getStudent_id() {
return student_id;
}
public void setStudent_id(int student_id) {
this.student_id = student_id;
}
public String getStudent_name() {
return student_name;
}
public void setStudent_name(String student_name) {
this.student_name = student_name;
}
public String getStudent_email() {
return student_email;
}
public void setStudent_email(String student_email) {
this.student_email = student_email;
}
public int getStudent_age() {
return student_age;
}
public void setStudent_age(int student_age) {
this.student_age = student_age;
}
}
这是映射文件的<?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="Student">
<insert id="insert1" parameterType="com.oracle.po.Student">
insert into student(student_id,student_name,student_email,student_age)
values(#{student_id},#{student_name},#{student_email},#{student_age})
</insert>
</mapper>
|