www.pudn.com > Jsp-Blog.rar > ShowLogDao.java, change:2010-05-24,size:1020b


package myblog.dao; 
 
import java.sql.Connection; 
import java.sql.ResultSet; 
import java.sql.SQLException; 
import java.sql.Statement; 
import java.util.ArrayList; 
 
import myblog.commons.ConnectionPool; 
import myblog.entity.Logs; 
 
public class ShowLogDao { 
	public Connection conn = null; 
 
	public Statement stmt = null; 
 
	public ResultSet rs = null; 
 
	public ArrayList<Logs> showLog() { 
		ArrayList<Logs> list = new ArrayList<Logs>(); 
		conn = ConnectionPool.getConnection(); 
		String sql = "select rownum , logid,logtitle,username, logcontent, createdate from log where rownum < 10 order by createdate desc "; 
		try { 
			stmt = conn.createStatement(); 
			rs = stmt.executeQuery(sql); 
			while (rs.next()) { 
				Logs log = new Logs(rs.getString("logid"), rs 
						.getString("logtitle"), rs.getString("logcontent"), rs 
						.getString("username"), rs.getString("createdate")); 
				list.add(log); 
			} 
		} catch (SQLException e) { 
 
			e.printStackTrace(); 
		} 
		return list; 
 
	} 
 
}