www.pudn.com > Jsp-Blog.rar > LogDao.java, change:2010-05-23,size:755b


package myblog.dao; 
 
import java.sql.Connection; 
import java.sql.PreparedStatement; 
import java.sql.SQLException; 
 
import myblog.commons.ConnectionPool; 
 
public class LogDao { 
	public Connection conn = null; 
 
	public PreparedStatement pstmt = null; 
 
	public int logInsert(String logtitle, String logcontent, String username) { 
		int num = 0; 
		conn = ConnectionPool.getConnection(); 
		String sql = "insert into log(logtitle,logcontent,username) values(?,?,?)"; 
		try { 
			pstmt = conn.prepareStatement(sql); 
			pstmt.setString(1, logtitle); 
			pstmt.setString(2, logcontent); 
			pstmt.setString(3, username); 
			num = pstmt.executeUpdate(); 
		} catch (SQLException e) { 
			 
			e.printStackTrace(); 
		} 
		return num; 
 
	} 
 
}