www.pudn.com > Jsp-Blog.rar > ShowUserInforDao.java, change:2010-05-25,size:1247b


package myblog.dao; 
 
import java.sql.Connection; 
import java.sql.PreparedStatement; 
import java.sql.ResultSet; 
import java.sql.SQLException; 
import java.util.ArrayList; 
 
import myblog.commons.ConnectionPool; 
import myblog.entity.Users; 
 
public class ShowUserInforDao { 
	public Connection conn = null; 
 
	public PreparedStatement pstmt = null; 
 
	public ResultSet rs = null; 
 
	public ArrayList<Users> showUserInfor(String username) { 
		ArrayList<Users> list = new ArrayList<Users>(); 
		conn = ConnectionPool.getConnection(); 
		String sql = "select user_name,user_pw,user_sex,user_question,user_answer,user_email,user_content,user_createdate from users where user_name=? "; 
		try { 
			pstmt = conn.prepareStatement(sql); 
			pstmt.setString(1, username); 
 
			rs = pstmt.executeQuery(); 
			while (rs.next()) { 
				Users user = new Users(null, rs.getString("user_name"), rs.getString("user_pw"), 
						rs.getString("user_sex"), rs.getString("user_question"), rs.getString("user_answer"), rs 
								.getString("user_email"), rs 
								.getString("user_content"), rs 
								.getString("user_createdate")); 
				list.add(user); 
			} 
		} catch (SQLException e) { 
			e.printStackTrace(); 
		} 
		return list; 
	} 
 
 
}