src/com/movie/dao/CommentDao.java

(开头部分) 6KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

package com.movie.dao;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;

import com.movie.pojo.Comment;

public class CommentDao extends Dao{
	int flag=0;
	/**
	 * 添加一条影评记录
	 * @param notice
	 * @return 标识flag 
	 */
	public int commentAdd(Comment comment){
    	try{
    	  this.getConnection();
    	  String sql="insert tb_comment values('"+comment.getMovieId()+"',?,?,?,0,?)";
    	  pstat=cn.prepareStatement(sql);
    	  pstat.setString(1,comment.getCommentTitle());
    	  pstat.setString(2,comment.getCommentContent());
    	  pstat.setString(3,comment.getSubmitTime());
    	
    	  pstat.setString(4,comment.getAuthor());
    	  flag=pstat.executeUpdate();
    	  System.out.println("commentdao29:"+flag);
    	}catch(SQLException e){
    		e.printStackTrace();
    	}
    	return flag;
    	
    }
	/**
	 * 查询所有影评记录
	 * @return 记录集合list
	 */
	public List<Comment> getCommentByName(String typeId){
		List<Comment> list = new ArrayList<Comment>();
    	try{
    	  this.getConnection();
    	  String sql;
    		  sql="select * from v_comment where commentTitle like '%"+typeId+"%'";
    	  pstat=cn.prepareStatement(sql);
    	  rs=pstat.executeQuery();
    	
    	  while(rs.next()){
    		  Comment comment=new Comment();
    		  comment.setId(rs.getString(1));
    		  comment.setAuthor(rs.getString("author"));
    		  comment.setCommentContent(rs.getString("commentContent"));
    		  comment.setMovieId(rs.getString("kindId"));
    		  comment.setSubmitTime(rs.getString("submitTime"));
    		  comment.setCommentTitle(rs.getString("commentTitle"));
    		  comment.setReadNum(rs.getString("readNum"));
    		  comment.setMovieType(rs.getString("kindName"));
    		  comment.setMovieName(rs.getString("movieName"));
    		  comment.setPhoto(rs.getString("photo"));
    		  list.add(comment);
后面还有 181 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。