日期:2014-05-17 浏览次数:21069 次
package com.niit.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import com.niit.entity.Student;
import com.niit.iface.IStuDao;
public class StudentDao extends BaseDao implements IStuDao
{
private Connection con;
private ResultSet rs;
private PreparedStatement pstmt;
public ArrayList<Student> findAllStudent()
{
ArrayList<Student> stuList=new ArrayList<Student>();
con=getConnection();
if(con!=null)
{
try
{
pstmt=con.prepareStatement("select * from student");
rs=pstmt.executeQuery();
//此处为false,但是上面的sql语句在oracle中能查到,为啥这里查不到呢
System.out.println(rs.next());
while(rs.next())
{
Student stu=new Student();
stu.setStuName(rs.getString(1));
stu.setStuId(rs.getInt(2));
stu.setBirthday(rs.getTimestamp(3));
stu.setSex(rs.getString(4));
stu.setEmail(rs.getString(5));
stuList.add(stu);
}