www.pudn.com > Jsp-Blog.rar > BlogUsersDao.java, change:2010-05-26,size:1064b


package myblog.dao; 
 
import java.sql.Connection; 
import java.sql.PreparedStatement; 
import java.sql.ResultSet; 
import java.sql.SQLException; 
import java.sql.Statement; 
import java.util.ArrayList; 
 
import myblog.commons.ConnectionPool; 
import myblog.entity.Users; 
 
public class BlogUsersDao { 
	public Connection conn = null; 
 
	public Statement stmt = null; 
 
	public ResultSet rs = null; 
 
	public ArrayList<Users> blogUsers() { 
		ArrayList<Users> list = new ArrayList<Users>(); 
		conn = ConnectionPool.getConnection(); 
		String sql = "select user_name,decode(user_sex,'1','男','0','女')user_sex,user_email,user_content from users"; 
		try { 
			stmt = conn.createStatement(); 
			rs = stmt.executeQuery(sql); 
			while (rs.next()) { 
				Users user = new Users(null, rs.getString("user_name"), null, 
						rs.getString("user_sex"), null, null, rs 
								.getString("user_email"), rs 
								.getString("user_content"),null); 
				list.add(user); 
			} 
		} catch (SQLException e) { 
			e.printStackTrace(); 
		} 
		return list; 
	} 
 
}