50,530
社区成员
发帖
与我相关
我的任务
分享
//mapper
<select id="select" resultType="com.pojo.Student" parameterType="java.lang.String">
select * from user where name=#{gender}
</select>
//查询并print数据
public static void selectUser(){
SqlSession session= factory.openSession();
try {
Student s=new Student();
s=session.selectOne("mapper.StudentMapper.select", "male");
System.out.println(s.toString());
}
catch (Exception e) {e.printStackTrace();}
finally {session.close();}
}
//mapper
<select id="select" resultType="com.pojo.Student" parameterType="java.lang.String">
select * from user where name=#{gender}
</select>
public static void selectUser(){
SqlSession session= factory.openSession();
try {
//Student s=new Student();
List <Student>SList= new ArrayList<Student>();
SList=session.selectList("mapper.StudentMapper.select", "male");
System.out.println(SList.size());
for (Student student : SList) {
System.out.println(student.toString());
}
} catch (Exception e) {
e.printStackTrace();
}finally {
session.close();
}
}