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


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.Logs; 
 
public class LogAdminDao { 
	private Connection conn = null; 
 
	private PreparedStatement pstmt = null; 
 
	private ResultSet rs = null; 
 
	public ArrayList<Logs> selectLog(String logid) { 
		ArrayList<Logs> list = new ArrayList<Logs>(); 
		conn = ConnectionPool.getConnection(); 
		String sql = "select logid,logtitle,logcontent from log where logid=?"; 
		try { 
			pstmt = conn.prepareStatement(sql); 
			pstmt.setString(1, logid); 
			rs = pstmt.executeQuery(); 
			if (rs.next()) { 
				Logs log = new Logs(rs.getString("logid"), rs 
						.getString("logtitle"), rs.getString("logcontent"), 
						null, null); 
				list.add(log); 
			} 
		} catch (SQLException e) { 
			e.printStackTrace(); 
		} finally { 
			if (conn != null) { 
				try { 
					conn.close(); 
				} catch (SQLException e) { 
 
					e.printStackTrace(); 
				} 
			} else if (pstmt != null) { 
				try { 
					pstmt.close(); 
				} catch (SQLException e) { 
 
					e.printStackTrace(); 
				} 
			} 
		} 
		return list; 
	} 
 
}